Added sortByKey functions for Array<T>