ls sorting

features-42
deadc0de6 4 months ago
parent 9326911824
commit b7d6f21cc2

@ -10,6 +10,7 @@ import shutil
import time import time
from typing import List, Union, Tuple, Any, Optional, Dict, cast from typing import List, Union, Tuple, Any, Optional, Dict, cast
import anytree # type: ignore import anytree # type: ignore
from natsort import os_sort_keygen
# local imports # local imports
from catcli import nodes from catcli import nodes
@ -723,7 +724,9 @@ class Noder:
return found return found
# sort found nodes # sort found nodes
found = sorted(found, key=self._sort, reverse=self.sortsize) #found = os_sorted(found)
found = sorted(found, key=os_sort_keygen(self._sort))
#found = sorted(found, key=cmp_to_key(self._sort), reverse=self.sortsize)
# print the parent # print the parent
if fmt == 'native': if fmt == 'native':
@ -798,8 +801,10 @@ class Noder:
@staticmethod @staticmethod
def _sort_fs(node: NodeAny) -> Tuple[str, str]: def _sort_fs(node: NodeAny) -> Tuple[str, str]:
"""sorting nodes dir first and alpha""" """sort by name"""
return (node.type, node.name.lstrip('.').lower()) # to sort by types then name
# return (node.type, node.name)
return node.name
@staticmethod @staticmethod
def _sort_size(node: NodeAny) -> float: def _sort_size(node: NodeAny) -> float:

@ -3,3 +3,4 @@ types-docopt; python_version >= '3.0'
anytree; python_version >= '3.0' anytree; python_version >= '3.0'
pyfzf; python_version >= '3.0' pyfzf; python_version >= '3.0'
fusepy; python_version >= '3.0' fusepy; python_version >= '3.0'
natsort; python_version >= '3.0'

Loading…
Cancel
Save