Add temporary _sort_formats helper function