# reverse ## Category Array ## Arity **Unary** — `reverse `. ``` reverse ``` ## Description Reverses the order of elements in the array **in-place**. The array is modified directly. Returns `nil`. ## How It Works Calls `List.Reverse()` on the underlying list. All elements are reordered. O(n) time, O(1) extra space. ## Usage ### Basic reverse ```sqf _arr = [1, 2, 3, 4]; reverse _arr; // _arr is [4, 3, 2, 1] ``` ### Reverse iteration ```sqf _arr = ["a", "b", "c"]; reverse _arr; { systemChat _x } forEach _arr; // prints "c", "b", "a" ``` ### Palindrome check ```sqf _isPalindrome = { params ["_arr"]; _copy = +_arr; // shallow copy reverse _copy; str _arr == str _copy }; ``` ### Undo reverse ```sqf reverse _arr; // first reverse // ... do work ... reverse _arr; // restore original order ``` > **Note**: Unlike `sort`, `reverse` does not take a direction argument — it always reverses. ## Thread Safety **Not thread-safe**. Array must belong to the current scheduler. ## See Also - [sort](sort.md) — sort array - [select](select.md) — element access - [forEach](forEach.md) — iterate array