Dec-22-2017, 09:49 PM
>>> lis= [["id","type","city","price","rooms"],[0,"Flat","Prague",13000,5],[1,"Flat","Prague",1000,4],[2,"House","Prague",13020,10]] >>> sorted([item for item in lis if item[1]=='Flat' and item[2]=='Prague'], key=lambda x: x[3]) [[1, 'Flat', 'Prague', 1000, 4], [0, 'Flat', 'Prague', 13000, 5]]however this looks like list of lists created by reading entire csv file in memory. is that the case? You may want to use dict reader. it will make the code more readble