sort the results
fix order problem in the composition function