How to use sorting to arrange a list of words based on length, when equal use alphabetical order? (without comparison tools)
Asked
Active
Viewed 126 times
-3
-
Yes: 1) compare on length. 2) if the lengths happen to be equal: compare on contents. – wildplasser Mar 08 '15 at 22:38
-
Please clarify. What do you mean by 'comparison tool'? What have you done so far? – Mar 08 '15 at 22:43
-
Voted to close as unclear (please vote to close if you are able to do so) – halfer Jan 25 '16 at 21:27
1 Answers
-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
-
-
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