Question: In c++ How would you sort an array by comparing a position in the array. {city: Houston, age: 19, name:joe} {city: Dallas, age: 18, name:Andrew}

In c++ How would you sort an array by comparing a position in the array.

{city: Houston, age: 19, name:joe}

{city: Dallas, age: 18, name:Andrew}

{city: Austin, age: 20, name:bob}

Let's say you have to sort this array by city. How would you get the position the city's name starts at (position 7 from the beginning) and compare each

example:

the H in houston {city: [H]ouston....}

the D in dallas {city: [D]allas....}

the A in Austin {city: [A]ustin....}

so comparing H, D, A so the array sorted looks like this

{city: Austin, age: 20, name:bob}

{city: Dallas, age: 18, name:Andrew}

{city: Houston, age: 19, name:joe}

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!