Sort specific items of an array first
Posted
by Matt Huggins
on Stack Overflow
See other posts from Stack Overflow
or by Matt Huggins
Published on 2010-05-12T18:40:40Z
Indexed on
2010/05/12
18:54 UTC
Read the original article
Hit count: 312
I have a ruby array that looks something like this:
my_array = ['mushroom', 'beef', 'fish', 'chicken', 'tofu', 'lamb']
I want to sort the array so that 'chicken' and 'beef' are the first two items, then the remaining items are sorted alphabetically. How would I go about doing this?
© Stack Overflow or respective owner