How can i sort a file when given a list of various countries and their population size in two different files... How can i sort them together so that the output shows country and population...
please someone help me is for a assignment??? thanks

Recommended Answers

All 2 Replies

How can i sort a file when given a list of various countries and their population size in two different files... How can i sort them together so that the output shows country and population...
please someone help me is for a assignment??? thanks

since you're already working with files, I'm quite sure your course has covered Objects already.

create an Object 'Country' with two variables: name and population,
next to the setters and getters, write two methods: compareByName and compareByPopulation, which both take an instance of Country as a parameter.

compare them all, write the to a file

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.