Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This does not always return the correct result. For some input strings, it changes relative positions of the characters that are not in the ordering string.
def sort_string(str,ordering)
str.chars.sort_by { |c| ordering.index(c) || ordering.size}
end
p sort_string("bananapxcgsdfhjd", "anb").join("")
p "aaannbpxcgsdfhjd"
the sort_string method results in "aaannbcxp..." instead of "aaannbpxc...". I am running ruby 2.2.0p0