Orderby for 2D array/JSON


#1

Hi all, i have reached a certain problem regarding 2D array/json. What i am trying to do is orderBy the wait time for Day & Time from user’s device. Lets say its a Tue and the time is 1130, i want to sort the whole list based on those values by wait time.

controller:

$scope.HHmm = $filter('date')(new Date(), 'HHmm');
$scope.Day = $filter('date')(new Date(), 'EEE');

html:

<ion-item><span class="badge badge-assertive">No. of Customers, Est. Wait Time</span></ion-item> 
<ion-item ng-repeat="item in items | orderBy:??? |filter:search" item="item"  href="#/app/store/{{item.id}}">{{item.names}}
<span class="badge badge-assertive" ng-show="HHmm >= 1000 && HHmm < 1030">{{item[Day][0]['1000']}}, {{item[Day][0]['waitTime']}}</span>
<span class="badge badge-assertive" ng-show="HHmm >= 1030 && HHmm < 1100">{{item[Day][1]['1030']}}, {{item[Day][1]['waitTime']}}</span>
<span class="badge badge-assertive" ng-show="HHmm >= 1100 && HHmm < 1130">{{item[Day][2]['1100']}}, {{item[Day][2]['waitTime']}}</span>
 <span class="badge badge-assertive" ng-show="HHmm >= 1130 && HHmm < 1200">{{item[Day][3]['1130']}}, {{item[Day][3]['waitTime']}}</span>
<span class="badge badge-assertive" ng-show="HHmm >= 1200 && HHmm < 1230">{{item[Day][4]['1200']}}, {{item[Day][4]['waitTime']}}</span>
</ion-item>
</ion-list>

JSON File:

[{
    "id": "61",
    "names": "Test 1",
    "Mon": [
      {
        "1000": "5",
        "waitTime": "05"
      },
      {
        "1030": "10",
        "waitTime": "10"
      },
      {
        "1100": "15",
        "waitTime": "20"
      },
      {
        "1130": "20",
        "waitTime": "30"
      },
      {
        "1200": "20",
        "waitTime": "35"
      }
    ],
    "Tue": [{...}],
    "Wed":[{...}],
    "Thur":[{...}],
    "Fri": [{...}],
    "Sat":[{...}],
    "Sun":[{...}],
  }
]

Any help will be greatly appreciated. Thanks!