answersLogoWhite

0


Best Answer

Well, I don't know how to rewrite a string in alphabetical order with a function, but I think I know a way to get around it. Try it first before you put it in something. Also, if you need to do it often, make it into a function...

//is an example string

var myName = "jake";

//makes myName into an array that is "j", "a", "k", "e"

var myName_array = myName.split("");

//this changes it into "a", "e", "j", "k";

var myName_array_alphabetical = myName_array.sort();

//and this makes it back into a string."aejk"

var myName_alphabetical = myName_array_alphabetical.join("")

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Read a string and rewrite in alphabetical order?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How to write printf statement for read characters into array str until the letter p is encountered?

In pseudo-code: while ( not(end of string) and letter(string at position X) is not 'P' ){ add(array, newposition) = letter(string at position X); }


Write a program to read and print a strings in C plus plus?

#include #include using std::cin;using std::cout;using std::endl;using std::string;using std::getline;int main(){string myString = "";cout


What are the limitations of getchar and scanf functions for strings?

cause getchar only read a character and scanf read only word before first space but not other words and letters.


What is meant by string sorting in java?

string sorting means sorting the string array in a specific order an example is given below import java.io.*; public class stringArray {public static void main(String args[])throws IOException {String A[]=new String[10];int i=0,j=0;String tmp; InputStreamReader read=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(read); System.out.println("enter the names"); for(i=0;i<10;i++) A[i]=(in.readLine()); for(i=1;i<10;i++) { for(j=0;j<10-i;j++) { if(A[j].compareTo(A[j+1])>0) {tmp=A[j]; A[j]=A[j+1]; A[j+1]=tmp; } } } System.out.println("the sorted array is "); for(i=0;i<10;i++) System.out.println(A[i]); } } if the input is: enter the names kurian avinash thomson satheesh rahul rohir anand basil glen james the output will be : the sorted array is anand avinash basil glen james kurian rahul rohir satheesh thomson


What is difference between System.String and System.StringBuilder classes?

String and StringBuilder classes are used to store string values but the difference in them is that String is immutable (read only) by nature, because a value once assigned to a String object cannot be changed after its creation. When the value in the String object is modified, a new object is created, in memory, with a new value assigned to the String object. On the other hand, the StringBuilder class is mutable, as it occupies the same space even if you change the value. The StringBuilder class is more efficient where you have to perform a large amount of string manipulation.

Related questions

Manufacturers state the speeds of CD-RW drives in this order?

write speed, rewrite speed, read speed


Write a program in c which will read a string rewrite it in alphabetical order?

Here is a simple C program that reads a string from the user, then sorts the characters of the string in alphabetical order: #include <stdio.h> #include <string.h> int main() { char str[100]; printf("Enter a string: "); fgets(str, sizeof(str), stdin); int len = strlen(str); for (int i = 0; i < len; i++) { for (int j = i+1; j < len; j++) { if (str[i] > str[j]) { char temp = str[i]; str[i] = str[j]; str[j] = temp; } } } printf("The string in alphabetical order is: %s\n", str); return 0; }


How do you string a Peavey guitar?

You remove the old strings, then insert new ones in the same order. Read from the string pack which one is meant to be which. Order usually always goes from left to right thick to thin strings if looking at the fretboard from the front.


Rewrite this sentence using correct capitalization holidays in November?

this sentence would read, "Rewrite this sentence using correct capitalization holidays in November" hope that helps


How do you rewrite the statement 'mind you own business'?

It should read, "Mind your own business."


How can you use rewrite in a sentence?

I have several sentences for you.You need to rewrite this essay and correct the grammar and punctuation errors.I always do a rewrite of my stories after a week or so, because then I can look at the writing with a fresh mind.The teacher says she will rewrite the test question on the board since the copy came out too light to read.


Is DSS involved if your fail a drug test after you give birth?

Read and rewrite your question. It does not make sense.


How would their lifestyle be different from today?

You need to rewrite the question since the read can't know who "they" are to answer the question.


How can you read string in C language?

You mean read from file/standard input? With function fgets.


Do you read guitar tabs lines from e to E or is there like a certain order?

Sample Guitar Tab with no notes: E |-----------------------------| (this line signifies the thinnest string on your guitar) B |-----------------------------| G |-----------------------------| D |-----------------------------| A |-----------------------------| E |-----------------------------| (this line singnifies the thickest string on your guitar)


How getchar can be used to read multicharacter string?

[object Object]


Is Daniel Radcliffe was a widower with a four-year-old son?

You need to read your question out loud to yourself then rewrite it.