D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 9457 - isSorted(string) doesn't work
Summary: isSorted(string) doesn't work
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 regression
Assignee: Andrej Mitrovic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-05 17:08 UTC by bearophile_hugs
Modified: 2013-02-13 00:13 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2013-02-05 17:08:14 UTC
This used to print true-false, but in DMD 2.062alpha prints true-true on Windows:


import std.stdio, std.algorithm;
void main() {
    auto x = "abcd";
    writeln(isSorted(x));
    auto y = "acbd";
    writeln(isSorted(y));
}


Maybe this line:

https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm.d#L9237

        for (; !ahead.empty; ahead.popFront(), ++i)

Should be:

        for (; !ahead.empty; ahead.popFront(), r.popFront(), ++i)
Comment 1 bearophile_hugs 2013-02-05 18:10:44 UTC
A comment from Brad Anderson:

> Looks like line 9221 is essentially the same code so you may want
> to change that line too.
Comment 2 bearophile_hugs 2013-02-06 03:10:17 UTC
This used to work not too much time ago.
Comment 3 Andrej Mitrovic 2013-02-12 13:52:58 UTC
https://github.com/D-Programming-Language/phobos/pull/1136

Thanks for your fix Bearophile.
Comment 4 github-bugzilla 2013-02-12 14:43:43 UTC
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/98cb833137c1c7cb9a51e7acb3cdf43332e0c7ac
Fixes Issue 9457 - isSorted(string) does not work.

https://github.com/D-Programming-Language/phobos/commit/8bf6997acfdbe81442e4c3e4c3500b9197ffaaca
Merge pull request #1136 from AndrejMitrovic/Fix9457

Issue 9457 - isSorted(string) does not work.
Comment 5 github-bugzilla 2013-02-13 00:13:52 UTC
Commit pushed to staging at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/e652b208dce5b36ab4c4d6b38fc537edf7013148
Fixes Issue 9457 - isSorted(string) does not work.