1

I search a solution for solve this problem in JS. I've got an array with some objects, with a propery "name".

I would like to order this array by a user search value. For example if user search "th", i would like an array order name begin by "th"etc...

var arrayName = [];
var emp1 =  {nom: "Thomas"};
var emp2 =  {nom: "Anastasia"};
var emp3 =  {nom: "Arnaud"};
var emp4 =  {nom: "Thierry"};
arrayName.push(emp1);
arrayName.push(emp2);
arrayName.push(emp3);
arrayName.push(emp4);

arrayName.orderBy("th");

In this code, orderBy method will be good if return the array sort by "th" and so return first "Thierry" object and second "Thomas".

Thanks helping me !

blackarcanis
  • 542
  • 1
  • 4
  • 23
  • Sort array of objects: http://stackoverflow.com/questions/1129216/sorting-objects-in-an-array-by-a-field-value-in-javascript – dfsq Mar 04 '15 at 10:37
  • Please show us what you have already tried, and how the code looks now. – BenM Mar 04 '15 at 10:38
  • I saw this topic but i don't want to order by alphabetic or yes but only after the search of user like "Th" for found "Thomas" and not "Anastasia" first for example. – blackarcanis Mar 04 '15 at 10:40

0 Answers0