Fixed sorting and formatting