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"]