Type to search.

ES|QL MV_SORT function

Serverless

Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Serverless interfaces and procedures might differ from classic Elastic Stack deployments.

Stack

The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments.

This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

Sorts the values in a multi-value field.

Embedded
Embedded
field
Expression that can be null, a single value, or multiple values. If null, the function returns null.
order

Sort order. The valid options are ASC and DESC, the default is ASC.

Sorts a multivalued field in lexicographical order.

field order result
boolean keyword boolean
boolean boolean
date keyword date
date date
date_nanos keyword date_nanos
date_nanos date_nanos
double keyword double
double double
integer keyword integer
integer integer
ip keyword ip
ip ip
keyword keyword keyword
keyword keyword
long keyword long
long long
text keyword keyword
text keyword
unsigned_long keyword unsigned_long
unsigned_long unsigned_long
version keyword version
version version
ES|QL
ROW a = [4, 2, -3, 2]
| EVAL sa = mv_sort(a), sd = mv_sort(a, "DESC")
a:integer sa:integer sd:integer
[4, 2, -3, 2] [-3, 2, 2, 4] [4, 2, 2, -3]