sortBySimilarity method

List<SimilarityIndex> sortBySimilarity([
  1. bool descending = true
])

Sorts the collection of SimilarityIndex instances in descending order of SimilarityIndex.similarity.

Implementation

List<SimilarityIndex> sortBySimilarity([bool descending = true]) {
  final list = List<SimilarityIndex>.from(this);
  if (descending) {
    list.sort(((a, b) => b.similarity.compareTo(a.similarity)));
  } else {
    list.sort(((a, b) => a.similarity.compareTo(b.similarity)));
  }
  return list;
}