List.Reverse
ListReturns a new list with the elements in reverse order.
Syntax
List.Reverse(list as list) as listParameters
| Name | Type | Required | Description |
|---|---|---|---|
list | list | Yes | The list to reverse. |
Return Value
list — A new list with elements in reverse order.
Remarks
List.Reverse returns a new list with the elements in reversed order. The original list is not modified. The function has no parameters beyond the list itself and always reverses the entire list.
A common use case is reversing the result of a sort: List.Sort produces ascending order by default, and List.Reverse on the result gives descending order. However, for descending sorts it is more efficient and readable to pass Order.Descending directly to List.Sort. Use List.Reverse when you need to reverse for other reasons — for example, processing a timeline from newest to oldest, or displaying a ranked list in reverse order.
List.Reverse can also be used as a building block in more complex transformations: for example, to read a list from the end without knowing its length, or to mirror a sequence.
Examples
Example 2: Reverse a sorted list to get descending order
let
Values = {3, 1, 4, 1, 5, 9, 2, 6},
Sorted = List.Sort(Values),
Descending = List.Reverse(Sorted)
in
DescendingThe final output — the list of integers sorted in descending order.
Result | |
|---|---|
| 1 | {9, 6, 5, 4, 3, 2, 1, 1} |
Example 3: Reverse a list of text items
List.Reverse({"First", "Second", "Third", "Fourth"})Result | |
|---|---|
| 1 | {Fourth, Third, Second, First} |