javascript - angular array loop and sort function -


i have array of objects, each object contains following properties:

comments:"" id:1 inprogress:false jobdescription:null lastupdatedate:"07/08/2016" lastupdatedbyuser:"xxx@abc.com" product:"chicken" status:object templatename:"standard template" uploaddate:"07/08/2016 10:36:01" 

i need function in angular can loop through entire list , sort through uploaddate , have recent first, etc.

i tried using did not work:

vm.uploads = $filter('orderby')(vm.uploads, vm.uploads[0].uploaddate, reverse); 

array.prototype.sort enough :

vm.uploads.sort(function(a,b){    return  new date(a.uploaddate).gettime()- new date(b.uploaddate).gettime(); }) 

if want desc order , switch a & b


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -