Fixed out of Bounds exception when sorting.