Fixes sorting order in compare fn