# Alphabetically Ordering A List (with possibly an array)?

**URL:** <https://forum.kirupa.com/t/alphabetically-ordering-a-list-with-possibly-an-array/209369>\
**Category:** flash\
**Created:** [December 8, 2006, 2:28am UTC](https://forum.kirupa.com/t/alphabetically-ordering-a-list-with-possibly-an-array/209369 "2006-12-08T02:28:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![REEF](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@REEF](https://forum.kirupa.com/u/REEF)\
**Post date:** [December 8, 2006, 2:28am UTC](https://forum.kirupa.com/t/alphabetically-ordering-a-list-with-possibly-an-array/209369/1 "2006-12-08T02:28:24Z")

</div>

I need to be able to put in 200 names separated by new lines (firstName lastName) into a textbox and I need the second textbox to show me all these 200 names alphabetically ordered with the format of (lastName, firstName). I’ve tried many array functions (sort for example) but couldnt get it right.

If the lastName, firstName format is not possible, i’d just like it to at least reshuffle the first textbox and show all the inputs in an alphabetical order in the second textbox in firstName lastName format.

For example, I type in the following exactly how it shows (with new lines per name):

John Hoe  
George Glooney  
Suede Jubuck  
Panda Iris  
Shawn Hamilton

I press the order button and the 2nd textbox shows me:

**G** looney, George  
**Ha** milton, Shawn  
**Ho** e, John  
**I** ris, Panda  
**J** ubuck, Suede

Notice it goes by G-H(ha,ho)-I-J here, obviously. If this cannot be done, I’d like first name ordering:

**G** eorge Glooney  
**J** ohn Hoe  
**P** anda Iris  
**Sh** awn Hamilton  
**Su** ede Jubuck

The comma’s arent necessary, at all, but it’s a nice fix. Any other suggestions are welcome. Thanks.
