Tova 122 Posted September 20, 2019 Hello ! I have an array of objects in the format : [obj_10,obj_1,obj_12,obj_13,obj_14,obj_11,obj_2,obj_3,obj_4,obj_5,obj_6,obj_7,obj_8,obj_9] I would like to sort this array so it becomes : [obj_1,obj_2,obj_3,obj_4,obj_5,obj_6,obj_7,obj_8,obj_9,obj_10,obj_11,obj_12,obj_13,obj_14] Also please note that the array contains objects and not strings ! I tried the sort function on the array, but no luck 😕 I believe the problem arises from alphabetical sorting as obj_11 comes before obj_2. Any ideas on how to get around the issue ? Thanks for the help ! Share this post Link to post Share on other sites
Mr H. 400 Posted September 20, 2019 _sorted= [_yourArray, [], {(str _x splitString "_")select 1}, "ASCEND"] call BIS_fnc_sortBy; try this (untested 1 Share this post Link to post Share on other sites
Tova 122 Posted September 20, 2019 Smart move ! It didn't work as it is, but you just forgot to add a ParseNumber since the third parameter of sortBy has to return a number 🙂 _sorted= [_yourArray, [], {parseNumber ((str _x splitString "_") select 1)}, "ASCEND"] call BIS_fnc_sortBy; Thanks a lot ! Share this post Link to post Share on other sites
Mr H. 400 Posted September 20, 2019 Just now, Tova said: It didn't work as is, you just forgot to add a ParseNumber ah s*** I was meaning to... Share this post Link to post Share on other sites
killzone_kid 1326 Posted September 20, 2019 Name them obj_01, obj_02.... then 11 will go after 02 1 Share this post Link to post Share on other sites