Skip to content
Advertisement

jQuery sort different class elements by attribute

There is two arrays that display information appending elements to the document. They are being printed in ascending order, but when it comes to organize them all, I can’t organize them individually by data attribute.

This function does the sort but can’t mix different element classes:

JavaScript

Before the above code this is where I print the two different element classes (avaibleRaffle and reservedRaffle) using arrays of string and filtering them to display the correct result.

JavaScript

The a minimal reproducible example:

JavaScript
JavaScript
JavaScript

Advertisement

Answer

Since I couldn’t resolve this problem of printing in ascending order the numbers after validating it with sort. Besides the collaboration, I came with a solution that is only using forEach for comparison of arrays:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement