Search
 
SCRIPT & CODE EXAMPLE
 

DART

sort map keys dart

import 'dart:collection';

void main() {
  final sortedMap = SplayTreeMap<DateTime, double>((a, b) => b.compareTo(a));

  sortedMap[DateTime(2021, 1, 1)] = 1.0;
  sortedMap[DateTime(2021, 1, 3)] = 3.0;
  sortedMap[DateTime(2021, 1, 4)] = 4.0;
  sortedMap[DateTime(2021, 1, 2)] = 2.0;
  sortedMap[DateTime(2021, 1, 5)] = 5.0;

  sortedMap.entries.forEach(print);
  // MapEntry(2021-01-01 00:00:00.000: 1.0)
  // MapEntry(2021-01-02 00:00:00.000: 2.0)
  // MapEntry(2021-01-03 00:00:00.000: 3.0)
  // MapEntry(2021-01-04 00:00:00.000: 4.0)
  // MapEntry(2021-01-05 00:00:00.000: 5.0)
}
Comment

PREVIOUS NEXT
Code Example
Dart :: data types in flutter 
Dart :: flutter sliver 
Dart :: how to blur container in flutter 
Dart :: flutter create new map 
Dart :: flutter multiple provider 
Dart :: flutter showSnackBar replacme 
Dart :: dart list generate 
Dart :: flutter compute 
Dart :: flutter overflow 
Dart :: flutter map key/value 
Dart :: class in dart 
Dart :: splash screen flutter null safety 
Dart :: upload zip file to ec2 
Dart :: 2d list in dart 
Dart :: flutter disable focusable 
Dart :: flutter api service example 
Dart :: get first word of a string before space flutter 
Dart :: dart string to int 
Dart :: dart get return value of future function 
Dart :: flutter set default language 
Dart :: dart typedef 
Dart :: dart 2d list join 
Dart :: text widget not recognize the currency symbol flutter 
Dart :: android emulator black screen flutter 
Dart :: a function body must be provided flutter 
Dart :: Ascending order with for loop in dart 
Dart :: flutter raised button shadow 
Swift :: regular expression for number less than 100 
Swift :: UI API called on a background thread 
Swift :: get request swift 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =