I have this collection from DataBase:
var items = [{ 'Name':'Michael', 'TypeId':1 }
{ 'Name':'Max', 'TypeId':1 }
{ 'Name':'Andre', 'TypeId':1 }
{ 'Name':'Georg', 'TypeId':2 }
{ 'Name':'Greg', 'TypeId':3 }
{ 'Name':'Mitchell', 'TypeId':2 }
{ 'Name':'Ptro', 'TypeId':1 }
{ 'Name':'Helga', 'TypeId':1 }
{ 'Name':'Seruin', 'TypeId':2 }
{ 'Name':'Ann', 'TypeId':3 }
{ 'Name':'Marta', 'TypeId':2 }]
I need to sort this items by TypeId increasing.
Like that:
var itemsSorted = [{ 'Name':'Michael', 'TypeId':1 }
{ 'Name':'Max', 'TypeId':1 }
{ 'Name':'Andre', 'TypeId':1 }
{ 'Name':'Ptro', 'TypeId':1 }
{ 'Name':'Helga', 'TypeId':1 }
{ 'Name':'Georg', 'TypeId':2 }
{ 'Name':'Mitchell', 'TypeId':2 }
{ 'Name':'Marta', 'TypeId':2 }]
{ 'Name':'Seruin', 'TypeId':2 }
{ 'Name':'Greg', 'TypeId':3 }
{ 'Name':'Ann', 'TypeId':3 }
Is there any built in function in JavaScript that can sort array of objects by property?
ng-repeat="items | orderBy: 'TypeId'"