deep-sort-list-parser 1.0.5__tar.gz → 1.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deep_sort_list_parser
3
- Version: 1.0.5
3
+ Version: 1.0.6
4
4
  Summary: A recursive data parser to flatten and sort complex nested structures safely.
5
5
  Author: Developer
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -1,5 +1,24 @@
1
1
  import collections
2
2
 
3
+ def deep_sort_dict(input_dict):
4
+ """
5
+ Takes any dictionary, sorts its keys alphabetically,
6
+ and checks if any of its values are ALSO dictionaries to sort them too!
7
+ """
8
+ sorted_dict = {}
9
+ sorted_keys = sorted(input_dict.keys(), key=str)
10
+
11
+ for key in sorted_keys:
12
+ value = input_dict[key]
13
+
14
+ # Use isinstance to support OrderedDict, Counter, and sub-dicts
15
+
16
+ if isinstance(value, dict): # RECURSION CHECK: If the value inside this key is ANOTHER dictionary,call deep_sort_dict
17
+ sorted_dict[key] = deep_sort_dict(value)
18
+ else:
19
+ sorted_dict[key] = value
20
+ return sorted_dict
21
+
3
22
  def clean_and_flatten(any_input, convert_numeric_strings = False):
4
23
  """
5
24
  Recursively flattens nested data structures and segregates types into sorted streams.
@@ -30,26 +49,7 @@ def clean_and_flatten(any_input, convert_numeric_strings = False):
30
49
  numbers = []
31
50
  words = []
32
51
  symbols = []
33
- dict_tracks = []
34
-
35
- def deep_sort_dict(input_dict):
36
- """
37
- Takes any dictionary, sorts its keys alphabetically,
38
- and checks if any of its values are ALSO dictionaries to sort them too!
39
- """
40
- sorted_dict = {}
41
- sorted_keys = sorted(input_dict.keys(), key=str)
42
-
43
- for key in sorted_keys:
44
- value = input_dict[key]
45
-
46
- # Use isinstance to support OrderedDict, Counter, and sub-dicts
47
-
48
- if isinstance(value, dict): # RECURSION CHECK: If the value inside this key is ANOTHER dictionary,call deep_sort_dict
49
- sorted_dict[key] = deep_sort_dict(value)
50
- else:
51
- sorted_dict[key] = value
52
- return sorted_dict
52
+ dict_tracks = []
53
53
 
54
54
  # HANDLE ACCIDENTAL INPUTS at entry level:
55
55
  # Supports custom lists/tuples/sets safely via Sequence checks
@@ -59,15 +59,15 @@ def clean_and_flatten(any_input, convert_numeric_strings = False):
59
59
  else:
60
60
  any_list = [any_input]
61
61
 
62
- def unpack(box):
63
62
 
63
+ def unpack(box):
64
64
  for item in box:
65
65
  if isinstance(item, (list, tuple, set)):
66
66
  unpack(item)
67
67
 
68
68
  # Find any dictionary inside the list box
69
69
  elif isinstance(item, dict):
70
- clean_dict = deep_sort_dict(item)
70
+ clean_dict = deep_sort_dict(item) #call global_helper_function
71
71
  dict_tracks.append(clean_dict)
72
72
 
73
73
  elif type(item) is bool:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "deep_sort_list_parser"
7
- version = "1.0.5"
7
+ version = "1.0.6"
8
8
  description = "A recursive data parser to flatten and sort complex nested structures safely."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"