Created
June 5, 2020 18:13
-
-
Save angeloped/548dc33bffaa9ff0208410eb459a2cf7 to your computer and use it in GitHub Desktop.
Geolocation Sorting Algorithm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sorted_geo = [] | |
def Geolocation_sorter(geo_info): # arg={COUNTRY:'',LNG:'',LAT:''} | |
if not bool(sorted_geo): # if empty | |
sorted_geo.append(geo_info) | |
return | |
i = 0 | |
while i < len(sorted_geo): | |
if (float(geo_info["LNG"]) >= float(sorted_geo[i]["LNG"]) and float(geo_info["LNG"]) <= float(sorted_geo[:i+1][0]["LNG"])): | |
sorted_geo.insert(i+1, geo_info) | |
break | |
elif (float(geo_info["LNG"]) < float(sorted_geo[i]["LNG"])): | |
sorted_geo.insert(i, geo_info) | |
break | |
else: | |
i += 1 | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment