Sort function works correctly now except for the "ELEM" field.

I will give a 1000 keys reward to the first person who posts a fix for sorting the "ELEM" field correctly.