DEV Community

loading...

Discussion on: Sorting HTML elements with Flexbox and JavaScript

Collapse
kevinhch profile image
Kevin

Pretty good code, but you can use the flex-direction: column-reverse; and some JS to get the same result

Collapse
nijeesh4all profile image
Nijeesh Joshy Author • Edited

Thats a really good point. we can use it to change the direction of the elements we cannot achieve sorting with that approach,
you wont get it sorted properly if the the elements are mixed.

say elements are in the order 1,2,3,4,9,5,10 so if you sorted it with flex-direction: column-reverse; what you will get is 10, 5, 9, 4, 3, 2, 1 its not what we are looking for.