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 +4 -0
- agisort-0.1.0/pyproject.toml +18 -0
- agisort-0.1.0/setup.cfg +4 -0
- agisort-0.1.0/src/agisort/__init__.py +3 -0
- agisort-0.1.0/src/agisort/agisort.py +26 -0
- agisort-0.1.0/src/agisort.egg-info/PKG-INFO +4 -0
- agisort-0.1.0/src/agisort.egg-info/SOURCES.txt +7 -0
- agisort-0.1.0/src/agisort.egg-info/dependency_links.txt +1 -0
- agisort-0.1.0/src/agisort.egg-info/top_level.txt +1 -0
agisort-0.1.0/PKG-INFO
ADDED
|
@@ -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"]
|
agisort-0.1.0/setup.cfg
ADDED
|
@@ -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 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
agisort
|