“Список заказов Дарт” Ответ

Список заказов Дарт

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');
}
askMe!

Сортировать список Дарт

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

Ответы похожие на “Список заказов Дарт”

Вопросы похожие на “Список заказов Дарт”

Больше похожих ответов на “Список заказов Дарт” по Dart

Смотреть популярные ответы по языку

Смотреть другие языки программирования