ee.List.sort
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Sắp xếp danh sách theo thứ tự tăng dần. Nếu bạn cung cấp đối số "keys", thì đối số này sẽ được sắp xếp trước và các phần tử của "list" sẽ được đặt theo cùng một thứ tự.
Cách sử dụng | Giá trị trả về |
---|
List.sort(keys) | Danh sách |
Đối số | Loại | Thông tin chi tiết |
---|
this: list | Danh sách | Danh sách cần sắp xếp. |
keys | Danh sách, mặc định: null | Khoá không bắt buộc để sắp xếp. Nếu bạn cung cấp "keys", thì trường này phải có cùng độ dài với "list". |
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eList.sort()\u003c/code\u003e arranges the elements of a list in ascending order, modifying the original list directly.\u003c/p\u003e\n"],["\u003cp\u003eAn optional \u003ccode\u003ekeys\u003c/code\u003e argument can be provided to specify the order in which elements should be sorted, requiring \u003ccode\u003ekeys\u003c/code\u003e to be the same length as the list being sorted.\u003c/p\u003e\n"]]],["The function `List.sort()` sorts a list in ascending order. It optionally accepts a `keys` argument, a list of the same length, to dictate the sort order. If `keys` is provided, the original `list` is reordered to match the sorted `keys`. The function returns the sorted `list`. If `keys` are not provided it sorts the list itself, by its values, in ascending order.\n"],null,["# ee.List.sort\n\nSorts the list into ascending order. If the 'keys' argument is provided, then it is sorted first, and the elements of 'list' are placed in the same order.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------------|---------|\n| List.sort`(`*keys*`)` | List |\n\n| Argument | Type | Details |\n|--------------|---------------------|------------------------------------------------------------------------------------------|\n| this: `list` | List | The list to sort. |\n| `keys` | List, default: null | Optional keys to sort by. If 'keys' is provided, it must have the same length as 'list'. |"]]