Made the function also return the array, so it's consistent with how Array#sort() works