-2

I have one issue about code solving challenge... as the last requirement it says that if score of two people are equal, then sort them alphabetically, for instance:

in case: Matthew and Elizabeth, the first comes Matthew in case: Chloe and Abigail, the first comes Abigail in case: Isabella Natalie, the first comes Isabella

Who can explain the logic of sorting them? If we say just comparing letters, the first case should be Elizabeth, not Matthew

  • With the information that you've given us, the assignment is clearly wrong, since Matthew coming before Elizabeth is not alphabetical sorting. But I feel that there is important information that is missing from your question. Such as the scores of the two people. – Erwin Bolwidt Feb 11 '21 at 23:24
  • Is there a last name also? Sorting by name usually means sorting by last name, then first name. – NomadMaker Feb 12 '21 at 02:04

2 Answers2

0

I don't know the full problem so I can't say for sure, but you said that "if the score of two people are equal, then sort alphabetically." Most likely then, Elizabeth has a lower score than Matthew. If Elizabeth and Matthew had the same score then Elizabeth would appear first.

My Boi
  • 23
  • 1
  • 4
0

Try this using a Map by sorting by value and then key, assuming the score is the value and name is the key.

check this out implementation of above suggestion

srd
  • 66
  • 6