promotion image of download ymail app

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

  • 9 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

    • Commenter avatarLogin to reply the answers
  • 9 years ago

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

    • Commenter avatarLogin to reply the answers
  • Anonymous
    9 years ago

    Yes I can

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