Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
April 18, 2011 [Issue 5854] New: Built-in array sort doesn't sort SysTime | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5854 Summary: Built-in array sort doesn't sort SysTime Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: Jesse.K.Phillips+D@gmail.com CC: Jesse.K.Phillips+D@gmail.com --- Comment #0 from Jesse Phillips <Jesse.K.Phillips+D@gmail.com> 2011-04-18 11:23:02 PDT --- This could be related to Issue 5853, Sorting SysTime: overlapping array copy. But I didn't see anything obviously wrong with SysTime. import std.datetime; void main() { auto arr = [ SysTime(DateTime(2011,4,4)), SysTime(DateTime(2011,3,22)) ]; auto ans = [ SysTime(DateTime(2011,3,22)), SysTime(DateTime(2011,4,4)) ]; arr.sort; assert(arr == ans); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 18, 2011 [Issue 5854] Built-in array sort doesn't sort SysTime correctly | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5854 kennytm@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code OS/Version|Windows |All --- Comment #1 from kennytm@gmail.com 2011-04-18 12:30:54 PDT --- It does sort the array, but not correctly, e.g. ----------------------------------------- import std.datetime, std.stdio; void main() { auto arr = [ SysTime(DateTime(2011,4,4)), SysTime(DateTime(2011,1,2)), SysTime(DateTime(2011,2,9)), SysTime(DateTime(2011,3,22))]; writeln(arr); arr.sort; writeln(arr); } ----------------------------------------- prints [2011-Apr-04 00:00:00, 2011-Jan-02 00:00:00, 2011-Feb-09 00:00:00, 2011-Mar-22 00:00:00] [2011-Jan-02 00:00:00, 2011-Apr-04 00:00:00, 2011-Mar-22 00:00:00, 2011-Feb-09 00:00:00] -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 18, 2012 [Issue 5854] Built-in array sort doesn't sort SysTime correctly | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5854 kekeniro2@yahoo.co.jp changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kekeniro2@yahoo.co.jp Component|DMD |Phobos --- Comment #2 from kekeniro2@yahoo.co.jp 2012-10-17 19:21:30 PDT --- The cause is in Phobos library.(std.datetime) Struct SysTime has some opCmp, but lacks the required one to overload. http://dlang.org/arrays.html#array-properties > For the .sort property to work on arrays of structs or unions, the struct or union definition must define the function: int opCmp(ref const S) const. The type S is the type of the struct or union. This function will determine the sort ordering. # I have no idea whether DMD could print an error or not. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation