I have an array named @level1 which has a value like this:
[
[3.1, 4],
[3.0, 7],
[2.1, 5],
[2.0, 6],
[1.9, 3]
]
I want to split this into two arrays such that the first array (@arr1) contains the values till 2.1 and the second array (@arr2) contains values after it.
After doing that, I would reverse-sort my second array by doing something like this:
@arr2 = @arr2.sort_by { |x, _| x }.reverse
I would then like to merge this array to @arr1. Can someone help me how to split the array and then merge them together?
@arr1 = { [3.1, 4], [3.0, 7]}@arr2 = { [2.1, 5], [2.0, 6], [1.9, 3]}Then I will reverse sort @arr2 which will give me the follwoing:@arr2 = { [1.9, 3] , [2.0, 6], [2.1, 5]}And then i would merge these 2 arrays