phorce 131 Posting Whiz in Training Featured Poster

Hey..

Is it possible to make PHP type arrays? Like keys?

For example, I have an array of numbers, and an array of letters..

A = 10
B = 20
C = 30

And then I sort the numbers so that the highest number is at the top etc.. But, it changes the values e.g:

A = 30 // But A = 10

So is there an array that could do this, or anyone suggest any alternative solution to the problem? I use bubble sort that looks like:

void sort_array(int *array, int alphaArray*, int length)//Bubble sort function 
{
    int i,j;
    for(i=0;i<26;i++)
    {
        for(j=0;j<i;j++)
        {
            if(array[i]>array[j])
            {
                int temp=array[i]; //swap 
                array[i]=array[j];
                array[j]=temp;
            }   
        }
    }
    
}

and my array of letters are like:

const char letters[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

Any help would be great, thank you :)

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.