Fix bug in llListSortStrided producing incorrect results sometimes

It used `a = lst[i]` instead of taking the stride index into account (that is, it should have been `a = lst[i+idx]`). Anyway, the exact same value is in b, so use that instead.

Test case by Tapple Gao.
This commit is contained in:
Sei Lisa 2024-10-09 01:37:34 +02:00
parent d2f81046d5
commit 1d6bb809bf
3 changed files with 16 additions and 2 deletions

View file

@ -1704,8 +1704,8 @@ def llListSort(lst, stride, asc, idx=0):
# swap # swap
lst[i:i+stride],lst[j:j+stride] = lst[j:j+stride],lst[i:i+stride] lst[i:i+stride],lst[j:j+stride] = lst[j:j+stride],lst[i:i+stride]
# Re-cache # Re-cache
a = lst[i] a = b
ta = type(a) ta = tb
if ta == Vector: if ta == Vector:
a = v2f(a) a = v2f(a)
a = a[0]*a[0] + a[1]*a[1] + a[2]*a[2] a = a[0]*a[0] + a[1]*a[1] + a[2]*a[2]

View file

@ -7,3 +7,4 @@
+ "T7" + llListSortStrided([1, "C", 3, "A", 2, "B"], 2, -3, TRUE) + "T7" + llListSortStrided([1, "C", 3, "A", 2, "B"], 2, -3, TRUE)
+ "T8" + llListSortStrided([1, "C", 3, "A", 2, "B"], 2, -2, TRUE) + "T8" + llListSortStrided([1, "C", 3, "A", 2, "B"], 2, -2, TRUE)
+ "T9" + llListSortStrided([1, "C", 3, "A", 2, "B"], 2, -1, TRUE) + "T9" + llListSortStrided([1, "C", 3, "A", 2, "B"], 2, -1, TRUE)
+ "T10" + llListSortStrided([1, "b", 0, "c", 1, "a", 0, "b", 1, "c", 0, "a"], 2, 1, TRUE)

View file

@ -49,4 +49,17 @@
, "B" , "B"
, 1 , 1
, "C" , "C"
, "T10"
, 1
, "a"
, 0
, "a"
, 0
, "b"
, 1
, "b"
, 1
, "c"
, 0
, "c"
] ]