Merge sort an array of objects based on a property or sort an array of values