Fixed bug on sort