main() { List customers = []; customers.add(Customer('Jack', 23)); customers.add(Customer('Adam', 27)); customers.add(Customer('Katherin', 25)); customers.sort((a, b) => a.age.compareTo(b.age)); print('Sort by Age: ' + customers.toString()); customers.sort((a, b) => a.name.compareTo(b.name)); print('Sort by Name: ' + customers.toString()); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter