Question: C++ array soriting function I need a function which sort the following data by population in ascending order please help!! thank you so much and

C++ array soriting function

I need a function which sort the following data by population in ascending order please help!! thank you so much and please show the sample output! just for heads up there are states which got 2 word might be a problems and the population has comma between number

I wirthe a function to delete comma you might need this:

void removeStuff(string& str, char character)

{

size_t pos;

while( (pos=str.find(character)) != string::npos )

str.erase(pos, 1);

}

states.txt:

 Idaho Boise 1,297,274 Washington Olympia 5,908,684 Vermont Montpelier 609,890 Hawaii Honolulu 1,216,642 Arizona Phonenix 5,140,683 Montana Helena 905,316 Virginia Richmond 7,100,702 North Dakota Bismarck 643,756 Colorado Denver 4,311,882 Mississippi Jackson 2,852,927 Delaware Dover 785,068 Georgia Atlanta 8,206,975 South Carolina Columbia 4,025,061 Illinois Springfield 12,439,042 Nebraska Lincoln 1,715,369 Arkansas Little Rock 2,679,733 New Hampshire Concord 1,238,415 Ohio Columbus 11,374,540 Kansas Topeka 2,693,824 Louisiana Baton Rouge 4,480,271 Michigan Lansing 9,955,829 Florida Talahasse 16,028,890 Connecticut Hartford 3,409,535 Iowa Des Moines 2,931,923 West Virginia Charleston 1,813,077 Missouri Jefferson 5,606,260 Wyoming Cheyenne 495,304 California Sacramento 33,930,798 Alabama Montgomery 4,461,130 New Jersey Trenton 8,424,354 South Dakota Pierre 756,874 Maryland Annapolis 5,307,886 Indiana Indianapolis 6,090,782 Oklahoma Oklahoma City 3,458,819 North Carolina Raleigh 8,067,673 New York Albany 19,004,973 Rhode Island Providence 1,049,662 Massachusetts Boston 6,355,568 Texas Austin 20,903,994 Kentucky Frankfort 4,049,431 Alaska Juneau 628,933 Utah Salt Lake City 2,236,714 Nevada Carson City 2,002,032 Maine Augusta 1,277,731 Tennessee Nashville 5,700,037 New Mexico Santa Fe 1,823,821 Oregon Salem 3,428,543 Minnesota St. Paul 4,925,670 Wisconsin Madison 5,371,210 Pennsylvania Harrisburg 12,300,670 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!