Skip to content

Commit

Permalink
Sort the ps output
Browse files Browse the repository at this point in the history
Provide consistent ordering for the ps command - longest duration listed first
  • Loading branch information
dhiltgen committed Jun 21, 2024
1 parent 9929751 commit 642cee1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,11 @@ func (s *Server) ProcessHandler(c *gin.Context) {
models = append(models, mr)
}

slices.SortStableFunc(models, func(i, j api.ProcessModelResponse) int {
// longest duration remaining listed first
return cmp.Compare(j.ExpiresAt.Unix(), i.ExpiresAt.Unix())
})

c.JSON(http.StatusOK, api.ProcessResponse{Models: models})
}

Expand Down

0 comments on commit 642cee1

Please sign in to comment.