共用方式為


sort operator

Applies to: ✅Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

依照一或多個資料行的順序來排序輸入資料表其資料列。

sortorder 運算符相等

Syntax

T| sort bycolumn [asc | desc] [nulls first | nulls last] [, ...]

Learn more about syntax conventions.

Parameters

Name 類型 Required Description
T string ✔️ 要排序的表格式輸入。
column scalar ✔️ The column of T by which to sort. 數據行值的型別必須是數值、日期、時間或字串。
ascdesc string asc 排序為遞增順序,低到高。 默認值為 desc,高到低。
nulls firstnulls last string nulls first 會將 Null 值放在開頭,並將 nulls last Null 值放在結尾。 asc預設值為 nulls firstdesc預設值為 nulls last

Returns

根據提供的數據行,以遞增或遞減順序排序的輸入數據表複本。

使用特殊的浮點值

當輸入資料表包含特殊值nullNaN-inf+inf時,順序會如下所示:

Value Ascending Descending
Nulls first nullNaN-inf-505+inf nullNaN+inf50-5
Nulls last -inf-50+infNaNnull +inf50-5NaNnull

Note

  • Null 和 NaN 值一律會分組在一起。
  • Null 和 NaN 值之間的順序是由第一個和最後一個屬性所決定,因為 null 和 NaN 沒有遞增和遞減順序。

Example

下列範例會依狀態依字母順序顯示 storm 事件,每個狀態中最新的風暴都會先出現。

The examples in this article use publicly available tables in the help cluster, such as the StormEvents table in the Samples database.

The examples in this article use publicly available tables, such as the Weather table in the Weather analytics sample gallery. 您可能需要修改範例查詢中的資料表名稱,以符合工作區中的資料表。

StormEvents
| sort by State asc, StartTime desc

Output

此數據表只會顯示前10個查詢結果。

StartTime State EventType ...
2007-12-28T12:10:00Z ALABAMA Hail ...
2007-12-28T04:30:00Z ALABAMA Hail ...
2007-12-28T04:16:00Z ALABAMA Hail ...
2007-12-28T04:15:00Z ALABAMA Hail ...
2007-12-28T04:13:00Z ALABAMA Hail ...
2007-12-21T14:30:00Z ALABAMA Strong Wind ...
2007-12-20T18:15:00Z ALABAMA Strong Wind ...
2007-12-20T18:00:00Z ALABAMA Strong Wind ...
2007-12-20T18:00:00Z ALABAMA Strong Wind ...
2007-12-20T17:45:00Z ALABAMA Strong Wind ...
2007-12-20T17:45:00Z ALABAMA Strong Wind ...