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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…