Search
 
SCRIPT & CODE EXAMPLE
 

DART

order list dart

void main() {
  List<Map<String, dynamic>> myProducts = [
    {"name": "Shoes", "price": 100},
    {"name": "Pants", "price": 50},
    {"name": "Book", "price": 10},
    {"name": "Lamp", "price": 40},
    {"name": "Fan", "price": 200}
  ];

  // Selling price from low to high
  myProducts.sort((a, b) => a["price"].compareTo(b["price"]));
  print('Low to hight in price: $myProducts');

  // Selling price from high to low
  myProducts.sort((a, b) => b["price"].compareTo(a["price"]));
  print('High to low in price: $myProducts');
}
Comment

sort list dart

List<int> nums = [13, 2, -11];
nums.sort();
print(nums);  // [-11, 2, 13]
Comment

PREVIOUS NEXT
Code Example
Dart :: canonical tag 
Dart :: hide keyboard flutter 
Dart :: color of status bar flutter 
Dart :: appbar icon 
Dart :: how to print in the same line in dart 
Dart :: options = null firebaseoptions cannot be null when creating the default app. flutter 
Dart :: dart timer delay 
Dart :: flutter launcher icon generate 
Dart :: raisedbutton shape flutter 
Dart :: how to get screen size in flutter 
Dart :: flutter path join 
Dart :: dart inset all 
Dart :: flutter snackbar width 
Dart :: no scroll physics flutter 
Dart :: text in column flutter overflow ellipsis not working 
Dart :: list of strings in dart 
Dart :: flutter slider color 
Dart :: change password firebase flutter 
Dart :: how to give bottom padding in Listview in flutter 
Dart :: StateError (Bad state: No element) 
Dart :: how to launch url in flutter web 
Dart :: transparent appbar flutter 
Dart :: dart for each indexed 
Dart :: flutter sliver grid 
Dart :: dart else if 
Dart :: transform widget flutter 
Dart :: string to int in dart 
Dart :: flutter auto size text 
Dart :: flutter = How to set Scrollbar colour in flutter? 
Dart :: Add Underline Text in Flutter 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =