1515 1/21/2025
1616
1717Version:
18- 5.0 .0
18+ 5.1 .0
1919"""
2020
2121
@@ -28,12 +28,13 @@ def memorySort(lst: list, mode: str = '') -> list:
2828
2929 mode (str):
3030 : (default) = sorts list using mode of first element in the given list
31- : 'i' or 'int' = list containing integers
31+ : 'a' or 'ascii' = list containing strings (sorted based on string ascii value)
32+ : 'c' or 'chr' = list containing characters
3233 : 'f' or 'float' = list containing float
34+ : 'i' or 'int' = list containing integers
3335 : 'n' or 'None' = list containing integers with no repeats
34- : 'c' or 'chr' = list containing characters
3536 : 's' or 'str' = list containing strings (sorted based on letter order)
36- : 'a' or 'ascii' = list containing strings (sorted based on string ascii value)
37+
3738
3839
3940 Returns:
@@ -42,12 +43,15 @@ def memorySort(lst: list, mode: str = '') -> list:
4243
4344
4445 if mode == '' :
45- if isinstance (lst [0 ], int ):
46- return memorySortI (lst )
47- if isinstance (lst [0 ], float ):
48- return memorySortF (lst )
49- if isinstance (lst [0 ], str ):
50- return memorySortS (lst )
46+ if isinstance (lst , list ):
47+ if isinstance (lst [0 ], int ):
48+ return memorySortI (lst )
49+ if isinstance (lst [0 ], float ):
50+ return memorySortF (lst )
51+ if isinstance (lst [0 ], str ):
52+ return memorySortS (lst )
53+ elif isinstance (lst , str ):
54+ return memorySortString (lst )
5155
5256
5357 if mode .lower () == 'i' or mode .lower () == 'int' or mode .lower () == '' :
@@ -171,7 +175,7 @@ def memorySortC(lst: list) -> list:
171175
172176
173177def memorySortA (lst : list ) -> list :
174- """Sorts the inputted list of string elements in ascending order based on string ascii value utilizing memory to speed up computation time
178+ """Sorts the inputted list of string elements in ascending order based on ascii value utilizing memory to speed up computation time
175179
176180 Args:
177181 lst (list): List of string elements to get sorted
@@ -328,4 +332,15 @@ def memorySortS(lst: list) -> list:
328332 output [p ] = chr (o + low ) + amount [o ][a ]
329333 p : int = p + 1
330334
335+ return output
336+
337+
338+
339+ def memorySortString (string : str ) -> str :
340+ temp = memorySortC (string )
341+ output = ''
342+
343+ for t in temp :
344+ output = output + t
345+
331346 return output
0 commit comments