I have an array of N elements and this array contains either 0, 1 or nil.
I want to get all indexes at which nil is present or sort the array so that all nil comes first.
I am looking for an efficient way because the array size can be very large.
Here is my code
array_of data # array with lots of 1, 0 and nil
temp = []
array_of_data.each_with_index {|a,i| (array_of_data[i] ? true : temp << i )}
Alternatives for you to benchmark: