How is sorted() used when a sort is needed on field other than 0?
This is part of my code.py.
Code: Select all
print("Seq\tECN\tSSID\t\t dBm\tMAC Address\t\tChan\tFoffs\tFcal")
X = 1
for ap in sorted(esp.scan_APs()):
# aps.append(ap)
S = "." * (18 - len(str(ap[1])))
print("{0:2}\t{1:}\t{2:}{3:}{4:}\t{5:}\t{6:}\t{7:}\t{8:}".format(X,ap[0],ap[1],S,ap[2],ap[3],ap[4],ap[5],ap[6]))
X += 1
print(" ECN = 0:OPEN 1:WEP 2:WPA_PSK 3:WPA2_PSK 4:WPA_WPA2_PSK 5:WPA2_Enterprise")
Code: Select all
Scanning for WiFi Access Points
Seq ECN SSID dBm MAC Address Chan Foffs Fcal
1 0 ESP_F66B11........-47 84:f7:03:f6:6b:11 11 -22 0
2 0 MOTOROLA-33113....-84 f8:35:dd:ef:f6:b8 1 -19 0
3 3 ATTBYax2BA........-51 ea:07:b6:e9:f9:68 10 -6 0
4 3 Blakes 2.4 GHz....-50 d8:07:b6:e9:f9:68 10 -6 0
5 3 Fios-Q7ZSV........-58 18:78:d4:3c:91:62 1 16 0
6 3 bblake............-80 10:da:43:cf:3b:de 1 3 0
7 4 ATTBYax2BA........-75 12:da:43:cf:3b:df 1 3 0
8 4 Ubiquiti..........-56 c8:3a:35:02:73:e0 10 0 0
9 4 adafruit..........-44 c0:56:27:c2:40:95 10 -9 0
10 4 adafruit..........-36 e0:b2:60:5c:23:b9 11 -2 0
11 4 bblake............-50 e0:b2:60:65:d2:79 4 -2 0
12 4 bblake............-45 58:d9:d5:59:1f:41 7 -17 0
ECN = 0:OPEN 1:WEP 2:WPA_PSK 3:WPA2_PSK 4:WPA_WPA2_PSK 5:WPA2_Enterprise
######## ########
This is what has been sorted before it is printed.
Code: Select all
[[0, 'ESP_F66B11', -43, '84:f7:03:f6:6b:11', 11, -24, 0],
[3, 'ATTBYax2BA', -44, 'ea:07:b6:e9:f9:68', 10, -7, 0],
[3, 'Blakes 2.4 GHz', -47, 'd8:07:b6:e9:f9:68', 10, -7, 0],
[3, 'Fios-Q7ZSV', -57, '18:78:d4:3c:91:62', 1, 15, 0],
[3, 'bblake', -71, '10:da:43:cf:3b:de', 1, 3, 0],
[4, 'ATTBYax2BA', -71, '12:da:43:cf:3b:df', 1, 1, 0],
[4, 'Ubiquiti', -53, 'c8:3a:35:02:73:e0', 10, -2, 0],
[4, 'adafruit', -42, 'c0:56:27:c2:40:95', 10, -9, 0],
[4, 'adafruit', -34, 'e0:b2:60:5c:23:b9', 11, -2, 0],
[4, 'aristotle', -61, '50:0f:f5:6b:74:01', 6, 0, 0],
[4, 'aristotle', -52, 'e0:b2:60:52:f9:99', 3, 13, 0],
[4, 'bblake', -48, 'e0:b2:60:65:d2:79', 4, -2, 0],
[4, 'bblake', -41, '58:d9:d5:59:1f:41', 7, -17, 0]]
Thanks,
Bruce