I found a Practice question from Anand Chitipothu. I found an answer on gist for a question(Not cheating, just couldn't understand where to start because new to python). Since the guy who posted it doesn't seem to be answering back, I'd like help in understanding the code, which runs. Won't name the guy, because that sounds a little mean. The question is to sort a list of filenames based on extension.
After splitting each list member by '.', which just forms a nested list, i think.
# using while loop on list and splitting it
i=0
while(i<len(x)):
x[i]=x[i].split('.')
i=i+1
He writes this:
x.sort(key=lambda x:x[1])
how does sort() know when key = x[1], it means x[1] of EACH sublist(which should be written as x[][1]) and not just the parent list?