ee.FeatureCollection.sort

Sắp xếp một bộ sưu tập theo thuộc tính đã chỉ định.

Trả về bộ sưu tập đã sắp xếp.

Cách sử dụngGiá trị trả về
FeatureCollection.sort(property, ascending)Bộ sưu tập
Đối sốLoạiThông tin chi tiết
this: collectionBộ sưu tậpPhiên bản Bộ sưu tập.
propertyChuỗiThuộc tính để sắp xếp.
ascendingBoolean, không bắt buộcCó sắp xếp theo thứ tự tăng dần hay giảm dần hay không. Giá trị mặc định là true (tăng dần).

Ví dụ

Trình soạn thảo mã (JavaScript)

// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
             .filter('country_lg == "Belgium"');

print('Belgium power plants in ascending order by capacity',
      fc.sort('capacitymw'));

print('Belgium power plants in descending order by capacity',
      fc.sort('capacitymw', false));

Thiết lập Python

Hãy xem trang Môi trường Python để biết thông tin về API Python và cách sử dụng geemap cho quá trình phát triển tương tác.

import ee
import geemap.core as geemap

Colab (Python)

# FeatureCollection of power plants in Belgium.
fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(
    'country_lg == "Belgium"')

print('Belgium power plants in ascending order by capacity:',
      fc.sort('capacitymw').getInfo())

print('Belgium power plants in descending order by capacity:',
      fc.sort('capacitymw', False).getInfo())