             populateSlots()
           else
             populateRecords()
-          if Key != oldKey || Order.length != Rows.length
-            Order = if Rows.length then [0..Rows.length-1] else []
           $scope.count = Rows.length
           $(TBody).empty()
           Expanded = undefined
           Rows[-1] = foot if foot
           populateCols(bySlot)
+          if Key != oldKey || Order.length != Rows.length
+            Order = if Rows.length then [0..Rows.length-1] else []
+            currentSort = undefined
+            sortBy(Cols.find((c) -> c.category.id == 'slot' && c.metric.id == 'date'))
           for i in Order
             generateRow(i)
           if Editing

            info.cell = info.tr.appendChild(document.createElement('td'))
            generateText(info)
            return
          if info.category.id == 'slot' && info.slot.top
            generateCell(l-1) # summary
            info.cell.setAttribute("colspan", l)
            return

            currentSortDirection = !currentSortDirection
            Order.reverse()
          else
            unless currentSort
              Order.sort (i, j) -> byNumber(Rows[i].key?.id, Rows[j].key?.id)
            c = col.category.id
            m = col.metric.id
            sort (i) ->
