View Single Post
Old 12-04-2012, 06:25 PM   #1
ww_crimson
Member
 
Join Date: Sep 2011
Home MUD: Aarchon
Posts: 62
ww_crimson is on a distinguished road
Really struggling with qsort (sorted areas list)

Hey all.. I'm a relatively inexperienced coder and I'm really struggling with grasping the concept of qsort and manipulating arrays.

I want to sort our area list by level (from smallest to largest) and it seems that qsort is the best way to do this from the research that I've done. I've added two integers to our AREA_DATA struct. int minlevel, and int maxlevel.

I've been looking at this old post from Erwin as a reference but I'm still stumped.

Putting all of the areas in the array, and then running them through areas[] and displaying the information is what I am particularly struggling with.

To put the areas into an array, I think a for_loop is probably the best solution, but I don't know exactly how to do this. Here is a simple loop that I've started on, but I'm not even really certain that it's correct.

This gives me a total count of the areas that I want to include, but it certainly doesn't add them to an array, and once I figure that out I'm still not sure how to run through the array displaying the information that I want.

Any help is appreciated. Please keep in mind I'm relatively new to this.

Thank you
ww_crimson is offline   Reply With Quote