sorting is working correctly now