sortProperties method

List<JsonPath> sortProperties(
  1. Iterable<JsonPath> source
)

Implementation

List<JsonPath> sortProperties(Iterable<JsonPath> source) {
  final toSort = {...source};
  final sorted = <JsonPath>[];
  for (final p in sortOrder) {
    if (toSort.contains(p)) {
      sorted.add(p);
      toSort.remove(p);
    }
  }
  for (final p in source) {
    // If it's still in the toSort set, then we need to add it (using the original order)
    if (toSort.contains(p)) {
      sorted.add(p);
    }
  }
  return sorted;
}