Skip to content

Random sorting#1223

Open
evergreenbear wants to merge 1 commit into9001:hovudstraumfrom
evergreenbear:randsort
Open

Random sorting#1223
evergreenbear wants to merge 1 commit into9001:hovudstraumfrom
evergreenbear:randsort

Conversation

@evergreenbear
Copy link

Hi,
I want to preface this by saying that this is both my first PR to any project and my first time doing anything with Javascript. However it is very much working (for me, at least) on both Firefox and Chromium.
image
This adds a new sorting option, random, that shuffles the contents of the directory in a unique order each time it is selected.

I imagine there are likely changes that still need to be made for this to be production-ready which I had not managed to catch, but I figured I got somewhere and this may still be useful.
I modified make-sfx.sh because cp would error on that command without -r on the system I was using to build (AlmaLinux amd64), and the script would not finish.

This PR complies with the DCO; https://developercertificate.org/

@9001
Copy link
Owner

9001 commented Jan 19, 2026

Hey :>

I'm curious to hear the reason you want to add this; what's the usecase?

@evergreenbear
Copy link
Author

Truthfully, my use case is to randomly sort albums of old photos to look through for fun, though I imagine this would be more useful if used in conjunction with a slideshow feature for e.g. turning an old device into a digital photo frame

@overcastbulb
Copy link

This looks like a useful addition! Random sorting is a common ask for media-heavy use cases like photo browsing and digital photo frames. The implementation is small and focused.
A few things worth checking before merge:

Is the shuffle using Math.random() directly? If so, consider whether Fisher-Yates shuffle would be more appropriate for uniform randomness
Does the random order reset/reshuffle each time the option is selected, or does it persist?

Either way, great first PR @evergreenbear — would love to see this merged! 🎉

@Kistras
Copy link

Kistras commented Mar 17, 2026

I would love to see this feature in copyparty and I really wanted it in my instance. Unfortunately it doesn't feel ready at the moment

I suggest detaching it from regular sorting so that you can't select "random" as primary and "name"/other as secondary sorting options. Sorting direction shouldn't matter for it
image

Table header in list view is broken: it's displayed in an incorrect place. Hiding it hides "type" column instead. I believe it shouldn't appear as a header at all (more points to it being a separate button)
image

Random sorting doesn't apply upon reloading the page or loading more items if a directory contains a lot of items. If it were to apply, I suggest storing a seed somewhere and using that so that sorting is reproduceable (with something like sfc32: https://stackoverflow.com/a/47593316)

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

Successfully merging this pull request may close these issues.

4 participants