Skip to content

Commit

Permalink
Sort containers and images by id if creation date is the same
Browse files Browse the repository at this point in the history
  • Loading branch information
vv9k committed Dec 3, 2021
1 parent 4ac36bc commit 5b9146f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,10 @@ impl App {
use ContainerEventResponse::*;
match event {
List(mut containers) => {
containers.sort_by(|a, b| b.created.cmp(&a.created));
containers.sort_by(|a, b| match b.created.cmp(&a.created) {
std::cmp::Ordering::Equal => a.id.cmp(&b.id),
cmp => cmp,
});
self.containers.containers = containers
}
Details(container) => self.set_container(container),
Expand Down Expand Up @@ -500,7 +503,10 @@ impl App {
use ImageEventResponse::*;
match event {
List(mut images) => {
images.sort_by(|a, b| b.created.cmp(&a.created));
images.sort_by(|a, b| match b.created.cmp(&a.created) {
std::cmp::Ordering::Equal => a.id.cmp(&b.id),
cmp => cmp,
});
self.images.images = images
}
Inspect(image) => self.images.current_image = Some(image),
Expand Down

0 comments on commit 5b9146f

Please sign in to comment.