/ Published in: Ruby
Public domain. Return a multidimensional array of array_to_sort and second_array, sorted by the values of array_to_sort.
Expand |
Embed | Plain Text
def sort_array_by_other_array(array_to_sort, second_array) combined_array = Array.new i = 0 for sortable_value in array_to_sort combined_array[combined_array.size] = [sortable_value, second_array[i]] i += 1 end combined_array = combined_array.sort { |x,y| x <=> y } return combined_array end
You need to login to post a comment.
