# How to sort words alphabetically from a String?

**URL:** <https://discourse.processing.org/t/how-to-sort-words-alphabetically-from-a-string/12767>\
**Category:** Coding Questions\
**Created:** [July 17, 2019, 9:47pm UTC](https://discourse.processing.org/t/how-to-sort-words-alphabetically-from-a-string/12767 "2019-07-17T21:47:38Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 18, 2019, 10:49am UTC](https://discourse.processing.org/t/how-to-sort-words-alphabetically-from-a-string/12767/6 "2019-07-18T10:49:48Z")

</div>

> [@lolonulu](#):
>
> , but still the order of the _word_ is messy in _x_,

There aren’t any variables named exactly _word_ nor _x_ in your posted code!

Also, you’re reassigning field _lines_ w/ another String[] array inside **draw()**:  
`lines = split(message, " ");`

Obviously after that, the previously **sort()** String[] array from **setup()** is gone!

However, all of this is already beyond what you had specifically requested in this topic here.

I believe this is all being debated in your previous topic below:

> [@How to break line using loadspring()?](https://discourse.processing.org/t/how-to-break-line-using-loadspring/12668/):
>
> Hello, I’d like to split my text into Strings and to move the same Strings to new coordinates. First when I split the text I don’t manage to insert a line break, how should I proceed? Thanks a lot in advance for your help. Best, L PFont f; String alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ2019,.;:!?\n "; String wordsList="FOLLY,WHAT,FOR,TO,IS,THE,WORD,ALL,GIVEN,IS,FROM,ALL,THAT,SEEING,THIS,SEE,GLIMPSE,NEED,SEEM,WHERE,OVER,AWAY,AFAR,AFAINT"; String []lines; String message; int posX = 20; int posY =…

---

_[View the full topic](https://discourse.processing.org/t/how-to-sort-words-alphabetically-from-a-string/12767)._
