--- id: sort title: sort Search Operator sidebar_label: sort description: Use the sort operator to order aggregated search results in descending order by default. slug: /help/docs/search/search-query-language/search-operators/sort/ canonical: https://www.sumologic.com/help/docs/search/search-query-language/search-operators/sort/ --- import useBaseUrl from '@docusaurus/useBaseUrl'; The `sort` operator orders aggregated search results. The default sort order is descending. Then you can use the top or limit operators to reduce the number of sorted results returned. The `order` operator is synonymous with the `sort` operator. You can use them interchangeably in your queries. ## Syntax `sort by (displays results as descending, by default)` `order by (displays results as descending, by default)` `sort by + (displays results as ascending)` `sort by asc (displays results as ascending)` `sort by , ` `top <#> ​​​​​​​ by ` ## Rules * Default sort order is descending. * Sorting is case sensitive with lower-case followed by upper-case. * To reverse the sort order to ascending, type a plus sign (+) before the field name you are sorting by. Alternatively, you can type **asc** after the field name. * To numerically sort, first [cast the field to a number](/docs/search/search-query-language/search-operators/manually-cast-data-string-number). Otherwise, the sort will be ordered as a text field. ## Examples ```sumo status AND down | extract "user=(?.*?):" | count (*) group by user | sort by _count ``` ```sumo ... | count user | top 2 user by _count ``` ```sumo ... | count user | sort by _count asc ``` ```sumo | parse "GET * " as url | count by url | order by _count | order by _count asc ``` ### Top 10 pages by page hits This example counts page hits by sourceHost, sorts them by page hits, and limits the results to the top 10. ```sumo _sourceCategory=Labs/Apache/Access | count as page_hits by _sourceHost | sort by page_hits | limit 10 ``` which provides results like: Sort For more information, see [Top](top.md) operator or [Limit](limit.md) operator.