finally got sorting to work