Do a case insenstive compare then case sensitive compare and finally
[dhcpcd-ui] / src / libdhcpcd / wpa.c
index 200e9ecf515026d07a5d088edb3908271339ca45..8a274405961993b3fc54bcd0332111a8d1c97543 100644 (file)
@@ -359,10 +359,15 @@ dhcpcd_wi_scan_compare(DHCPCD_WI_SCAN *a, DHCPCD_WI_SCAN *b)
 {
        int cmp;
 
+       /* Fist sort non case sensitive, then case sensitive */
        cmp = strcasecmp(a->ssid, b->ssid);
        if (cmp == 0)
-               /* Return strongest first */
+               cmp = strcmp(a->ssid, b->ssid);
+
+       /* If still the same, return strongest first */
+       if (cmp == 0)
                cmp = b->strength.value - a->strength.value;
+
        return cmp;
 }