agisort 0.1.0__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.
agisort-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,4 @@
1
+ Metadata-Version: 2.4
2
+ Name: agisort
3
+ Version: 0.1.0
4
+ Requires-Python: >=3.10
@@ -0,0 +1,18 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agisort"
7
+ version = "0.1.0"
8
+ requires-python = ">=3.10"
9
+
10
+ dependencies = [
11
+
12
+ ]
13
+
14
+ [tool.setuptools]
15
+ package-dir = {"" = "src"}
16
+
17
+ [tool.setuptools.packages.find]
18
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ from .agisort import agisort
2
+
3
+ __all__ = ['agisort']
@@ -0,0 +1,26 @@
1
+ import math
2
+ import heapq
3
+ from typing import List, Callable
4
+
5
+ def agisort(input_list: List[int], score: Callable[[object], int] = lambda x: x) -> List[int]:
6
+ n = len(input_list)
7
+ min_score = min(score(x) for x in input_list)
8
+ max_score = max(score(x) for x in input_list)
9
+ if min_score == max_score:
10
+ return input_list
11
+
12
+ heaps = [[] for _ in range(n)]
13
+
14
+ for ith_element in input_list:
15
+ ith_score = score(ith_element)
16
+ i = math.floor(((ith_score - min_score) / (max_score - min_score)) * (n - 1))
17
+ heapq.heappush(heaps[i], (ith_score, ith_element))
18
+
19
+ i = 0
20
+ for heap in heaps:
21
+ while heap:
22
+ ith_score, ith_element = heapq.heappop(heap)
23
+ input_list[i] = ith_element
24
+ i += 1
25
+
26
+ return input_list
@@ -0,0 +1,4 @@
1
+ Metadata-Version: 2.4
2
+ Name: agisort
3
+ Version: 0.1.0
4
+ Requires-Python: >=3.10
@@ -0,0 +1,7 @@
1
+ pyproject.toml
2
+ src/agisort/__init__.py
3
+ src/agisort/agisort.py
4
+ src/agisort.egg-info/PKG-INFO
5
+ src/agisort.egg-info/SOURCES.txt
6
+ src/agisort.egg-info/dependency_links.txt
7
+ src/agisort.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ agisort