Changed sorting

Should fix the corruption bug that people were having.