got sorting functionality working