I am trying to sort the scores in ascending order but I do not have any idea to do sorting in class. Any help will be appreciatd.

First, your comparison function needs to be able to access the private member text of myclass.

You could either make text public or add

friend int cmp (const void , const void);
in the class definition.

Second, your comparison function is wrong. It takes pointers to the members of the array to be sorted. You should write it like this for example:

int cmp (const void *ptr1 , const void *ptr2)
{
    myclass *m1 = *(myclass**)ptr1;
    myclass *m2 = *(myclass**)ptr2;

    return strcmp(m1->text, m2->text);
}

Learn C++ here https://hackr.io/tutorials/learn-c-c-plus-plus

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.