can anybody solve this?

create a function that can sort string. string function "string_sort(. . .)"

which sorts the characters in a string alphabetically (but putting all upper-case letters before all lower-case letters).

3 Answers

Relevance
  • 8 years ago
    Favorite Answer

    if it's in C++ :

    if it's type string, convert it to a char* type ( u can just strcpy(char*tpy , mainstring) )

    then include algorythm and use the "sort" function , as every character has an ASCII code this function just treat it as any other array of numbers and sorts it.

    lucky you Upper case by default have a smaller ASCII value than lower case :)

    oh and if use of "algorythm" is restricted just use any sort algorythm you know for normal numbers

    bubble sort, etc....

    hope that helps

    • Login to reply the answers
  • 8 years ago

    Return the ASCII code for each element,, then sort by that.

    • Login to reply the answers
  • Anonymous
    8 years ago

    Yes I can

    • Login to reply the answers
Still have questions? Get your answers by asking now.