React Typescript Array Sorting Function