So im using python (an older version) and i have a list of country names and an associated numbers, I need to sort these countries from highest to lowest in terms of that number,
Also I need to associate this list with another list, and there are some countries in the second list that are not in the first... durr?????
Congratulations, you discovered the Travelling Sussman Problem (names as such because Sussman kept a log file of his travels around the world that he wanted to keep sorted). That's a widely known problem that many beginners discover on their adventure with programming (as the rumor has it, Sussman discovered it when he was 11). Unfortunately, it's NP-hard and you can't do it in a language like python.
Also I need to associate this list with another list, and there are some countries in the second list that are not in the first... durr?????
What does that mean?
The first question can be done in CL rather easily:
CL-USER> (sort '((99 . country-b) (2 . country-a)) #'< :key #'car)
((2 . COUNTRY-A) (99 . COUNTRY-B))
The second one I don't really understand? Do you need to translate the country names based on some association list or hash table? That would very trivial thing to do.
How about you give the exact problem with example inputs and outputs?
Not that people will answer you in Python.
If you just wanted to translate a list of countries to something they're associated with, that would be trivial, just map over the list.
(mapcar #'translate-country countries)
;; translate-country would look up a key in a hashtable (as an example, it would be anything else) and replace it with a value
(defun translate-country (country)
(gethash countries *country-to-whatever-hashtable*))
>>25
Don't worry about him, he's an asshole. Python is a perfectly tractable language and will serve you fine should you ever learn to program.
Good luck with your English major, and be sure to drop by if you encounter any more problems!