Если я ничего не напутал, то пробуй это:
struct commandLine {
uint16_t timeFromStart;
uint8_t deviceName;
boolean onDevice;
uint16_t timeDeviceOn;
};
int compare(const void *i, const void *j);
void setup() {
Serial.begin(9600);
commandLine Formovka[] = {
(commandLine){ 17, 2, 1, 170 },
(commandLine){ 8, 3, 1, 88 },
(commandLine){ 5, 2, 1, 55 },
(commandLine){ 10, 3, 1, 100 },
(commandLine){ 21, 2, 1, 210 },
(commandLine) { 13, 3, 1, 130 }
};
int arrayLength = sizeof(Formovka) / sizeof(Formovka[0]);
qsort(Formovka, arrayLength, sizeof(commandLine), compare);
for (int i = 0; i < arrayLength; i++) {
Serial.print(i);
Serial.print(" - ");
Serial.println(Formovka[i].timeFromStart);
}
}
void loop() { }
int compare(const void *i, const void *j) {
return *(uint16_t *)j - *(uint16_t *)i;
}