Fixed bug with sorting.