P
Payton Swick
Hi,
I have an array of Strings, and I'd like to find one of the items by
Regexp, then move that item to the front of the array, eg:
array = %w(a B c d Cool e f G)
array.unshift(array.slice!(array.index(array.find { |i| i =~ /cool/i
}))) if array.find { |i| i =~ /cool/i }
Better/cleaner/shorter ways to do it?
-Payton
I have an array of Strings, and I'd like to find one of the items by
Regexp, then move that item to the front of the array, eg:
array = %w(a B c d Cool e f G)
array.unshift(array.slice!(array.index(array.find { |i| i =~ /cool/i
}))) if array.find { |i| i =~ /cool/i }
Better/cleaner/shorter ways to do it?
-Payton