From fbb11d0826b265e871f6676690ddf053760fba76 Mon Sep 17 00:00:00 2001 From: Jacob Pavlock Date: Sun, 2 Oct 2022 15:08:10 -0700 Subject: [PATCH] feat: list cli output is now sorted --- moe/library/lib_item.py | 4 ++++ moe/plugins/list.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/moe/library/lib_item.py b/moe/library/lib_item.py index 7453eb8e..792bc893 100644 --- a/moe/library/lib_item.py +++ b/moe/library/lib_item.py @@ -253,6 +253,10 @@ def __setattr__(self, name, value): else: super().__setattr__(name, value) + def __lt__(self, other): + """Library items implement the `lt` magic method to allow sorting.""" + raise NotImplementedError + class PathType(sa.types.TypeDecorator): """A custom type for paths for database storage. diff --git a/moe/plugins/list.py b/moe/plugins/list.py index 07644d4f..d2c28720 100644 --- a/moe/plugins/list.py +++ b/moe/plugins/list.py @@ -63,7 +63,7 @@ def _parse_args(args: argparse.Namespace): log.error("No items found to list.") raise SystemExit(1) - for item in items: + for item in sorted(items): if args.paths: print(item.path) else: