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

Sort images alphabetically #50

Open
aresundnes opened this issue Oct 17, 2016 · 2 comments
Open

Sort images alphabetically #50

aresundnes opened this issue Oct 17, 2016 · 2 comments

Comments

@aresundnes
Copy link

aresundnes commented Oct 17, 2016

The readdir() method sorts objects in the filesystem order, but i think it would be nice to sort images alphabetically so you can have some control of the order.

I've fixed it locally but want to suggest you change the code to something like this:

    $images = array();
    if ($handle = opendir($game.'/images'))
    {
        while (false !== ($entry = readdir($handle))) array_push($images, $entry);      
        sort($images);
    }

    foreach($images as $entry) 
    {
        // business as usual in here
    }

Anyway, thanks for a great project!

  • Are
@paulcanning
Copy link

On my local Windows machine, the images are already sorted alphabetically.

@samizzo
Copy link

samizzo commented Jun 14, 2017

@paulcanning on different file and operating systems the sort order will be different. The only way to guarantee an order is to explicitly sort it.

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

3 participants