ee.FeatureCollection.sort

按指定属性对集合进行排序。

返回已排序的集合。

用法返回
FeatureCollection.sort(property, ascending)集合
参数类型详细信息
此:collection集合Collection 实例。
property字符串要排序的属性。
ascending布尔值,可选是按升序还是降序排序。默认值为 true(升序)。

示例

代码编辑器 (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));

Python 设置

如需了解 Python API 和如何使用 geemap 进行交互式开发,请参阅 Python 环境页面。

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())