a = ['A', 'B', 'C', 'D', 'C']
target="C"
a.partition { |e| e==target }.reduce(:+)
#=> ["C", "C", "A", "B", "D"]
or
a.select { |e| e==target }.concat(a.reject { |e| e==target })
#=> ["C", "C", "A", "B", "D"]
a
is not modified.
1
solved Reorder array based on passed in value