0

I have object like this,

 {
Nov 17, 2016:Array[1]
Dec 1, 2016:Array[1]
Nov 22, 2016:Array[1]
Nov 23, 2016:Array[1]
Nov 21, 2016:Array[1]
}

i want to sort this as descending order in the same date format.
output should be... Thank's in advance.

{
 Dec 1, 2016:Array[1]
 Nov 23, 2016:Array[1]
 Nov 22, 2016:Array[1]
 Nov 21, 2016:Array[1]
 Nov 17, 2016:Array[1]
}

https://plnkr.co/edit/kZzxHDg1om7ylbGYeloe?p=preview plunker

1 Answers1

1

You just need to put

ng-repeat="message in data.messages | orderBy:'createdTime':true"

It will order your data in descending order of createdTime

<div class="panel panel-default"  ng-repeat="message in data.messages | orderBy:'createdTime':true">
   <div class="panel-heading" style="color:blue">{{ message.createdTime | date:'MMM d, yyyy' }}</div>
   <div class="panel-body" >
       <span  uib-tooltip="{{message.userName}}" tooltip-placement="top">{{ message.groupList[0].userName }}, {{ message.groupList[1].userName }}</span>
   </div>
</div>

Check

https://plnkr.co/edit/CbV3uQI8JoU2Wt0wFsSl?p=preview

Ali Mehdi
  • 770
  • 1
  • 8
  • 28
  • Thanks 4 answered @Ali Mehdi , but my requirement doesn't meet with your answer. I have filtered data as **GroupByDate** 4 the purpose of comparison with **current date & prev date to show today & yesterday** respectively. and **groupList** may contain more or less than two objects.It shouldn't be like messages.groupList[0]. – Omprakash Sharma Dec 06 '16 at 12:16