sort string

  • Thread starter Thread starter Hrvoje Voda
  • Start date Start date
H

Hrvoje Voda

I read a text file context into a string.
It's a sentence. - "Good day."
I would like to save it back to text file but as "Day good."

Hrcko
 
I read a text file context into a string.
It's a sentence. - "Good day."
I would like to save it back to text file but as "Day good."

Another employment test question? If so, I seriously hope you don't
get (correct) answers.

Jon
 
Create an array of strings from the string, sort the array, and create a
string from the array.

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
I read a text file context into a string.
It's a sentence. - "Good day."
I would like to save it back to text file but as "Day good."

Hrcko

Split the string around the space and place into a new string in the
correct order.
 
Hrvoje said:
I hope you don't speak with others in this way!

And we hope you find that it's better to learn the material rather than
having others take your interview tests for you. Will our hopes and
desires be fulfilled? Only time will tell.

Did it ever occur to you that if you have to ask other people for the
answers to your interview questions, you may not be the person your
prospective employer wants to hire?

Whatever you think of the interview practice of asking such questions,
clearly the employer in questions finds it of value. They are looking
for a specific kind of candidate, and you can't change yourself into
that kind of candidate just by asking people in this newsgroup to answer
the questions for you.

Unless your prospective employer is specifically looking for a person
who will delegate the answering of interview questions to others, it
seems like you're going about this in the wrong way.

Pete
 
Hrvoje Voda said:
I hope you don't speak with others in this way!

I speak with others who are trying to cheat in order to get a job in
this way.

I have a rather different attitude with people who are trying to solve
a problem honestly.
 
Hrvoje Voda said:
I hope you don't speak with others in this way!

Hrcko

Jon is one of the most well-spoken individuals in this group. If you find
him offensive, then either you misunderstood him or you have a guilt
complex. Because you replied and didn't deny that it is an interview
question, I suspect the latter.
 
Hrvoje said:
I read a text file context into a string.
It's a sentence. - "Good day."
I would like to save it back to text file but as "Day good."

1) use a parser generator to create a parser that parses the
file into words
2) for each word you store the word in database table with an
auto increment / identity column
3) then you select words from that table order by that column
descending
4) you concatenate the words to a string
5) write that string to a file

:-)

Arne
 
Hrvoje Voda said:
I read a text file context into a string.
It's a sentence. - "Good day."
I would like to save it back to text file but as "Day good."

1. Since you know that the file contains the string "Good day.", just
skip that step for efficiency.
2 Write the following program
public class Silly
{
static void Main()
{
System.Console.WriteLine("Day good.");
}
}

3. Compile program
4 Run as follows from the command line
Silly > Silly.out

There, perfect.
 
Back
Top