0

I'm using the NoCode-app Flutterflow - and I need a piece of code ;) to sort a firestore-collection. I'm sure it can't be that hard, but I'm trying this for 2 days now...

I want the function to return a sorted list, based on a string-argument.

When I create a "custom function" (that's how a piece of code is called in FlutterFlow) I get this template:

import 'dart:math' as math;

List<DocumentReference> sortImages(
  List<DocumentReference> listdocument,
  String sortBy,
) {
  return listdocument; '<<< what comes here? How do I sort?
}

How do I sort "sortImages" now by the argument "sortBy" and return it?

As you see I don't really have an idea of flutter/darts, and a NoSQL-db is also new to me... but I keep fighting to learn more every day!

Thanks a lot!

webwurm
  • 75
  • 1
  • 7

1 Answers1

0

sorry if it's too late, but have you read this post? How can I sort a list of strings in Dart?

There is a explanation of how to order string with different alternatives. This example should work in your custom function:

final List<String> fruits = <String>['bananas', 'apples', 'oranges'];
fruits.sort();
print(fruits);

Cheers!

Ariel-.

Ariel-.
  • 11
  • 1
  • 4
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 07 '22 at 11:15