79338912

Date: 2025-01-08 11:23:08
Score: 1.5
Natty:
Report link

How to sort a list of strings based on their lengths in dart.

List<String> words = ["mass","as","hero","superhero"];
words.sort((w1, w2) => w1.length.compareTo(w2.length));
print(words);

output:

["as", "mass", 'hero", "superhero"]
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): How to
  • Low reputation (1):
Posted by: Mustapha Adams