I need to shift an element to last position by condition.
For ex.
[1,2,3] and to put 1 in last in array, without executing unnecessary loops.
o/p [2,3,1] for the above condition array will be dynamic and put particular element on last by condition.
I tried like this:
sd = [1,2,3]
sd.map{|d| sd.last(d) if d ==1 }
but the output is [[3], nil, nil]