-3

How to use sorting to arrange a list of words based on length, when equal use alphabetical order? (without comparison tools)

halfer
  • 19,824
  • 17
  • 99
  • 186
iii
  • 1

1 Answers1

-1

Sort the list twice: First alphabetically, then by length. This will give you a list sorted by length, and then alphabetically for words of the same length. For example:

at
by
bat
cat
dog
aardvark

Is this what you need? Or do you need sample code as well?

Sandy Gettings
  • 693
  • 5
  • 21
  • This might have been downvoted because the OP is either lazy or a help vampire, and there is an unwritten rule not to feed such individuals. – halfer Jan 24 '16 at 19:45
  • Ok, thanks for that info. But why was my *answer* down-voted? – Sandy Gettings Jan 25 '16 at 20:18
  • That was my point - perhaps someone felt you were feeding a vampire, and that whilst vampires themselves should be downvoted, perhaps people encouraging them to stay ought to be discouraged too. (I personally don't downvote for this reason, but I do sometimes add a comment to achieve the same). – halfer Jan 25 '16 at 21:26