Fixed sorting. Sort by written instead of id.