By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,463 Members | 774 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,463 IT Pros & Developers. It's quick & easy.

Sorting: How to get permutation index?

P: 7
In C: Instead of actually sorting an array, how would you go about obtaining the index array mapping the sorted array to the original? The solution I have seen (http://www.freshsources.com/199300F2.HTM#00F2_007D) declares the array to be sorted globally at the top, creates a compare function that compares elements in this array and hands it to qsort (with an index array). This works in the hypothetical case that you know the array you want to sort before you write your code, but what is the workaround when the array is found at run time?
Sep 17 '06 #1
Share this Question
Share on Google+
1 Reply


P: 7
In the hypothetical case that anybody else would be as stupid as me: You only have to DECLARE the array to be sorted globally whereas you can fill in the values locally in your subroutines as you get to them.
Sep 21 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.