answersLogoWhite

0

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

12y ago

What else can I help you with?

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 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.


Bluej program-read a string and check if the given string is a palindrome?

import java.util.Scanner; public class Palindrome{ public static void main(String[] args){ String front; String back =""; char[] failure; String backwards; Scanner input=new Scanner(System.in); System.out.print("Enter a word: "); front=input.next(); front=front.replaceAll(" ", ""); failure=front.toCharArray(); for (int i=0; i<failure.length; i++){ back=failure[i] + back; } if (front.equals(back)){ System.out.print("That word is a palindrome"); }else System.out.print("That word is not a palindrome"); }}

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?

#include<stdio.h> #include<string.h> #include<conio.h> void main() { char a[30],temp; int n=0,j,i; clrscr(); printf("Enter the string\n"); gets(a); while(a[n]!='\0') { n++; } for(i=0;i<n;i++) { for(j=0;j<n-i-1;j++) { if(a[j]>a[j+1]) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } printf("The string in alphabetical order is\n"); for(i=0;i<n;i++) { printf("%c",a[i]); } getch(); }


How do I read tablature for guitar?

To read tablature for guitar, each line represents a string on the guitar, and numbers on the lines indicate which fret to press down. Start from the top line (thinnest string) to the bottom line (thickest string) to play the notes in order.


How to read tablature for guitar?

To read tablature for guitar, each line represents a string on the guitar, and numbers on the lines indicate which fret to press down. Start from the top line (the thinnest string) to the bottom line (the thickest string). Play the notes in the order they are written to play the song or riff.


How do you read tabs for playing guitar?

To read tabs for playing guitar, each line represents a string on the guitar, and numbers on the lines indicate which fret to press down. Start from the top line (the thinnest string) and play the notes in order.


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.


How to read a tab for playing guitar?

To read a tab for playing guitar, each line represents a string on the guitar, and the numbers on the lines indicate which fret to press down. Start from the top line (the thinnest string) and work your way down. Play the notes in the order they are written to create the music.


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.