in reply to Using map function to print few elements of list returned by sort function

Your desired output doesn't seem to match your stated objective, in that it lists cities from just two countries, ZM and ZW. Please clarify.

Second, where/how do you make the determination of the "top 4 populated countries?" Nothing you've shown makes that clear.

I, for one, would be a lot more inclined (and able) to help if there were fewer mysteries involved.



Quis custodiet ipsos custodes. Juvenal, Satires

  • Comment on Re: Using map function to print few elements of list returned by sort function

Replies are listed 'Best First'.
Re^2: Using map function to print few elements of list returned by sort function
by jaypal (Beadle) on May 25, 2014 at 02:33 UTC

    Thank you for the comment. My apologies for the confusion. The objective was to print top 4 populated cities for each country. The sample data has 2 countries present ZM and ZW. Each country has many cities listed.

    So I would like to print just the top 4 populated cities for each of them. If a country does not have 4 cities as in the case of ZM then print all lines.