Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting problem to php array #58

Open
shoniax opened this issue Apr 23, 2021 · 7 comments
Open

Sorting problem to php array #58

shoniax opened this issue Apr 23, 2021 · 7 comments

Comments

@shoniax
Copy link

shoniax commented Apr 23, 2021

Hello , when I change order of selected items I got random sort when i try to print it.

image

Here is the result
image

@haught
Copy link

haught commented Jun 22, 2021

I have the same problem, the user defined order is not preserved into the form submittal - it will always be the same order as the original left sided options.

@steveerg
Copy link

Same problem here ... left side options order rules on the right side.

@ataknakbulut
Copy link

Same problem here

@erenilhan
Copy link

+1

@arnofo
Copy link

arnofo commented Nov 30, 2022

I encounter the same problem but only on Chrome.
It works fine with Firefox.

I have run a few tests and it seems to come down to the browser sorting algorithm, maybe related to this explanation ?

https://stackoverflow.com/a/44120478

@ducvu91
Copy link

ducvu91 commented Oct 13, 2023

I checked it run in here https://preview.keenthemes.com/metronic/demo9/features/miscellaneous/dual-listbox.html
anyone have solution ?

@ssada1975
Copy link

_initializeSortButtons() {
let t = document.createElement("button");
t.classList.add("dual-listbox__button"), t.innerText = this.upButtonText, t.addEventListener("click", i => this._onSortButtonClick(i, h, 'selected'));
let e = document.createElement("button");
e.classList.add("dual-listbox__button"), e.innerText = this.downButtonText, e.addEventListener("click", i => this._onSortButtonClick(i, u, 'selected'));
let s = document.createElement("div");
s.classList.add("dual-listbox_sortButtons"), s.appendChild(t), s.appendChild(e), this.selectedListTitle.appendChild(s)

            t = document.createElement("button");
            t.classList.add("dual-listbox__button"), t.innerText = this.upButtonText, t.addEventListener("click", i => this._onSortButtonClick(i, h, 'available'));
            e = document.createElement("button");
            e.classList.add("dual-listbox__button"), e.innerText = this.downButtonText, e.addEventListener("click", i => this._onSortButtonClick(i, u, 'available'));
            s = document.createElement("div");
            s.classList.add("dual-listbox_sortButtons"), s.appendChild(t), s.appendChild(e), this.availableListTitle.appendChild(s)

        }

onSortButtonClick(t, e, as) {
t.preventDefault();
let list = this.dualListbox.querySelector(".dual-listbox
_"+as);
let orderedLIs = [...list.children].sort((a, b) =>
a.textContent.localeCompare(b.textContent)
);
if (e=="down") orderedLIs = orderedLIs.reverse();
list.innerHTML = orderedLIs.map(li => li.outerHTML).join('');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants