Two objects are sorted in JavaScript and two objects in Java are sorted

Source: Internet
Author: User

Array of objects in JavaScript sort

An array of objects that define an object

var text = [{"Name": "Zhang", "Age": 24},{"name": "Qin", "Age": 26},{"name": "Liu", "Age": 29},{"name": "Sagong", "Age": 78},{"name": "King", "Age": 90}];

Two write a custom sorting method

var buttern=function (x, y) {if (x.age<y.age) {return-1}else if (x.age>y.age) {return 1}else{return 0}};

Three sort

Text.sort (Buttern); The view structure is already lined up.

Sorting object Arrays in Java

The sort ( list <T> list, Comparator <? super T> c) method in the Java. Util. Collections Class

Two objects are sorted in JavaScript and two objects in Java are sorted

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.