Skript

Skript

788k Downloads

sort ... by map value unexpectedly removes duplicate elements

muhammetmatrix opened this issue · 1 comments

commented

Skript/Server Version

[22:16:05 INFO]: [Skript] Server Version: 1.21.4-2416-51aafbc (MC: 1.21.4)
[22:16:05 INFO]: [Skript] Skript Version: 2.11.1 (skriptlang-github)
[22:16:05 INFO]: [Skript] Installed Skript Addons:
[22:16:05 INFO]: [Skript]  - skript-gui v1.3.1 (https://github.com/APickledWalrus/skript-gui)
[22:16:05 INFO]: [Skript]  - ItemsAdder v4.0.10 (devs.beer)
[22:16:05 INFO]: [Skript]  - skript-reflect v2.6 (https://github.com/SkriptLang/skript-reflect)
[22:16:05 INFO]: [Skript]  - skript-placeholders v1.7.0 (https://github.com/APickledWalrus/skript-placeholders)
[22:16:05 INFO]: [Skript]  - SkBee v3.11.1 (https://github.com/ShaneBeee/SkBee)
[22:16:05 INFO]: [Skript]  - Lusk v1.3.5 (https://github.com/JakeGBLP/Lusk)
[22:16:05 INFO]: [Skript] Installed dependencies: None

Bug Description

Skript Version

[Your Skript version here, e.g. 2.7.3]

Issue Description

The following code is meant to sort a list of values based on a predefined map (_levels), including duplicates:

command /maps:
    trigger:
        set {_levels::a} to 1
        set {_levels::b} to 2
        set {_levels::c} to 3

        add (shuffled "a", "a", "b") to {_items::*}

        broadcast {_items::*}
        broadcast "-------------"

        sort {_items::*} in descending order by {_levels::%input%}

        broadcast {_items::*}

Expected Behavior

The list {_items::*} should still contain three elements after sorting (e.g. b, a, a depending on shuffle). Duplicates should be preserved.

Steps to Reproduce

After sorting, only two elements are present in _items::* — one of the "a" entries disappears.
This suggests that the sort ... by expression removes duplicates, even when the list initially includes them.

Errors or Screenshots

No response

Other

No response

Agreement

  • I have read the guidelines above and affirm I am following them with this report.
commented

Due to EffSort lines 103-120 using a 1:1 map instead of a 1:many map when mapping values.

This suggests that the sort ... by expression removes duplicates, even when the list initially includes them.

It does not. This is limited to EffSort.