ArraySort
Example of using the standard library algorithms.
- Boards: 🛈
- AVR, AVR USB, Nano Every, Nano 33 IoT, Nano 33 BLE, UNO R4, Pi Pico, Due, Teensy 3.x, ESP8266, ESP32
This sketch creates an array with an unordered sequence of 10 numbers. It prints the array, and then creates a reverse view on the 6 elements in the middle of the array and sorts it. The resulting array has the same elements in the 4 outermost places, but the 6 elements in the middle have been sorted in reverse order.
Output
Array< T, N > copyAs(const Array< U, N > &src)
Copy an Array to an Array of a different type.
Written by PieterP, 2019-11-12 https://github.com/tttapa/Arduino-Helpers
#include <AH/STL/algorithm>
;
Array<int, 10> array {3, 5, 9, 2, 1, 8, 6, 4, 7, 0};
Serial <<
" Sorting ├─────────────────┤ in ascending order"
Serial <<
" Sorting ├─────────────────┤ in descending order"
}
void loop() {}
Dummy header file for Arduino builder.
Print & endl(Print &printer)
An array wrapper for easy copying, comparing, and iterating.