diff --git a/esp8266_deauther/SimpleList.h b/esp8266_deauther/SimpleList.h index 58ed0b4..39b8da0 100644 --- a/esp8266_deauther/SimpleList.h +++ b/esp8266_deauther/SimpleList.h @@ -339,26 +339,24 @@ template void SimpleList::sort(std::function cmp) { // selection sort - int indexA; - int indexB; - Node* nodeA; // node at index i - Node* nodeB; // next minimum node + int indexH; // index of node i + int indexMin; // index of next minimum node + Node* nodeMin; // next minimum node Node* nodeH; // helper node at index j for(int i=0; idata, nodeH->data)){ - nodeB = nodeH; - indexB = j; + if(cmp(nodeMin->data, nodeH->data)){ + nodeMin = nodeH; + indexMin = j; } } - swap(indexA, indexB); + swap(indexH, indexMin); } } -#endif +#endif \ No newline at end of file