# Return every 'n' index of every string in array

**URL:** <https://forum.kirupa.com/t/return-every-n-index-of-every-string-in-array/331229>\
**Category:** Uncategorized\
**Created:** [June 17, 2013, 10:14pm UTC](https://forum.kirupa.com/t/return-every-n-index-of-every-string-in-array/331229 "2013-06-17T22:14:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jprivett](https://avatars.discourse-cdn.com/v4/letter/j/f07891/32.png) [@jprivett](https://forum.kirupa.com/u/jprivett)\
**Post date:** [June 17, 2013, 10:14pm UTC](https://forum.kirupa.com/t/return-every-n-index-of-every-string-in-array/331229/1 "2013-06-17T22:14:03Z")

</div>

Hello All,

I hope you all are doing wonderfully today.

I am trying to create a custom Rolodex/VoIP caller type mini app for my desktop.

I am getting my data from my localhost database and returning all my contacts information as strings to an array.

I have tabs(buttons) at the top for First Name, Middle Name, Last Name.

The strings in the array look something like this:  
“01, john, smith, [john.smith@smithconstruction.com](mailto:john.smith@smithconstruction.com), 555-555-5050,true”  
“02, jane, smith, [jane.smith@itemp.com](mailto:jane.smith@itemp.com), 555-555-0006, true”  
So forth and so on.

I have seen the Adobe help section using the following code:

```auto
var names:Array = new Array("John Q. Smith", "Jane Doe", "Mike Jones"); function orderLastName(a, b):int 
{ 
    var lastName:RegExp = /\b\S+$/; 
    var name1 = a.match(lastName); 
    var name2 = b.match(lastName); 
    if (name1 < name2) 
    { 
        return -1; 
    } 
    else if (name1 > name2) 
    { 
        return 1; 
    } 
    else 
    { 
        return 0; 
    } 
} 
trace(names); // output: John Q. Smith,Jane Doe,Mike Jones 
names.sort(orderLastName); 
trace(names); // output: Jane Doe,Mike Jones,John Q. Smith

```

But I want to be able to sort by any index in my string.  
Anyone have any knowledge and or hints on how to go about this?

Thank you in advance for looking.

-James
