FAQ Database Discussion Community

How do I sort an array alphabetically?

Having trouble with my syntax have tried a few things but still not getting it right. What am I not understanding? Thanks change = ['cents', 'pennies', 'coins', 'dimes', 'pence', 'quarters'] change.sort {|anythinghere| a <=> b puts "Ascending #{anythinghere}" } ...

Display a .txt file in alphabetical order in python [closed]

I have this .txt file Sam : 6 Peter : 9 Hubert: 4 Daniel : 2 Richard : 1 David : 8 Jesus : 10 What I want to do is (in my program) print out this .txt file but in alphabetical order. So my output would look like this:...

Sort by alphabetical permutation [closed]

I am trying to implement a sorting algorithm that sorts a list of words by a given alphabetical permutation. (For example, if given the permutation "zyxwvutsrqponmlkjihgfedcba" and a list of words "ant, bear, cat, zoo, animal" my algorithm would return "zoo, cat, bear, ant, animal") I can think of a...