# array sorts @ after numbers

**URL:** <https://forum.xojo.com/t/array-sorts-after-numbers/16408>\
**Category:** General\
**Created:** [May 10, 2014, 11:02am UTC](https://forum.xojo.com/t/array-sorts-after-numbers/16408 "2014-05-10T11:02:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Baka](https://forum.xojo.com/user_avatar/forum.xojo.com/paul_baka/32/4654_2.png) [@Paul\_Baka](https://forum.xojo.com/u/Paul_Baka)\
**Post date:** [May 10, 2014, 11:02am UTC](https://forum.xojo.com/t/array-sorts-after-numbers/16408/1 "2014-05-10T11:02:16Z")

</div>

howdy all,  
now i have been mucking around with an array. example of one with values would be ("#",“1”,“22”,"@",“d”,"/") and so on. all random values  
now i have noticed symbols like !,#,& will get sorted before numbers, but the @ will get sorted after numbers. This is sorting a string array  
anyone else found this issue? i would assume all weird symbols, characters would go first, then numbers, then letters, but it seems to get mixed up a bit.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [May 10, 2014, 1:44pm UTC](https://forum.xojo.com/t/array-sorts-after-numbers/16408/2 "2014-05-10T13:44:04Z")

</div>

sorting is lexical based on UTF8 character tables which, for any character whose code point is \< 127 follows ASCII  
so it will sort in the order of the ascii table  
[http://www.asciitable.com](http://www.asciitable.com)

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [May 10, 2014, 5:39pm UTC](https://forum.xojo.com/t/array-sorts-after-numbers/16408/3 "2014-05-10T17:39:35Z")

</div>

> [@87423:@Paul Baka](#):
>
> i would assume all weird symbols, characters would go first, then numbers, then letters

And you would be wrong. If you look at the table that Norman referenced, you will see that the numbers fall right in the middle of the “weird characters”. Namely,

!"#$%&'()\*=,-./0123456789:;\<=\>?@

---

<div class="post-metadata">

**Author:** ![DaveS](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/848f3c/32.png) [@DaveS](https://forum.xojo.com/u/DaveS)\
**Post date:** [May 10, 2014, 5:50pm UTC](https://forum.xojo.com/t/array-sorts-after-numbers/16408/4 "2014-05-10T17:50:41Z")

</div>

Another sorting “gotcha” is representing numbers as strings…

Strings sorting works like Norman mentioned above…

So if you had and array like (“1”,“2”,“3”,“20”,“30”,“100”)  
if would sort as

“1”,“100”,“2”,“20”,“3”,“30”

which is 100% legit… not a bug… it is what should happen.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:13pm UTC](https://forum.xojo.com/t/array-sorts-after-numbers/16408/5 "2020-10-29T17:13:13Z")

</div>


