mirror of
https://github.com/pocketpy/pocketpy
synced 2026-03-25 06:30:17 +00:00
Compare commits
No commits in common. "f5c67576aa793313fd7def8c6c250eddd0e0c763" and "30abdf652cc44c3e8b69ab316ebc1c4744699c54" have entirely different histories.
f5c67576aa
...
30abdf652c
@ -12,10 +12,10 @@ static bool _stable_sort_merge(char* a,
|
|||||||
int (*f_lt)(const void* a, const void* b, void* extra),
|
int (*f_lt)(const void* a, const void* b, void* extra),
|
||||||
void* extra) {
|
void* extra) {
|
||||||
while(a < a_end && b < b_end) {
|
while(a < a_end && b < b_end) {
|
||||||
int res = f_lt(b, a, extra);
|
int res = f_lt(a, b, extra);
|
||||||
// check error
|
// check error
|
||||||
if(res == -1) return false;
|
if(res == -1) return false;
|
||||||
if(res == 0) { // !(b<a) -> (b>=a) -> (a<=b)
|
if(res) {
|
||||||
memcpy(r, a, elem_size);
|
memcpy(r, a, elem_size);
|
||||||
a += elem_size;
|
a += elem_size;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -88,7 +88,7 @@ assert list(range(5, 1, -2)) == [5, 3]
|
|||||||
# test sort
|
# test sort
|
||||||
a = [8, 2, 4, 2, 9]
|
a = [8, 2, 4, 2, 9]
|
||||||
assert a.sort() == None
|
assert a.sort() == None
|
||||||
assert (a == [2, 2, 4, 8, 9]), a
|
assert a == [2, 2, 4, 8, 9]
|
||||||
|
|
||||||
a = []
|
a = []
|
||||||
assert a.sort() == None
|
assert a.sort() == None
|
||||||
|
|||||||
@ -143,9 +143,3 @@ class A:
|
|||||||
x: list[int] = [i for i in range(1, 4)]
|
x: list[int] = [i for i in range(1, 4)]
|
||||||
|
|
||||||
assert A.x == [1, 2, 3]
|
assert A.x == [1, 2, 3]
|
||||||
|
|
||||||
# stable sort
|
|
||||||
a = [(0, 1), (1, 1), (1, 2)]
|
|
||||||
b = sorted(a, key=lambda x: x[0])
|
|
||||||
if b != [(0, 1), (1, 1), (1, 2)]:
|
|
||||||
assert False, b
|
|
||||||
Loading…
x
Reference in New Issue
Block a user