digitalmars.D.bugs - [Issue 4909] New: Two suggestions for std.algorithm.schwartzSort()
- d-bugmail puremagic.com (42/42) Sep 21 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4909
- d-bugmail puremagic.com (7/7) Sep 16 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4909
- d-bugmail puremagic.com (15/15) Sep 16 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4909
- d-bugmail puremagic.com (21/24) Sep 16 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4909
- d-bugmail puremagic.com (20/43) Sep 16 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4909
- d-bugmail puremagic.com (8/10) Sep 16 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4909
- d-bugmail puremagic.com (13/13) Oct 01 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4909
- d-bugmail puremagic.com (6/6) Mar 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4909
- d-bugmail puremagic.com (13/15) Mar 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4909
- d-bugmail puremagic.com (11/11) Mar 23 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4909
- d-bugmail puremagic.com (15/19) May 24 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4909
http://d.puremagic.com/issues/show_bug.cgi?id=4909 Summary: Two suggestions for std.algorithm.schwartzSort() Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc Both my experience with Python and some practice with D v2 shows me that in script-like programs schwartzSort() is useful very often. Python 3 has even removed the "cmp" argument for its built-in sort, so it always performs a Schwartz sorting using the "key" argument, because it's simpler to use. This an usage example of schwartzSort usage, to sort an array of arrays according to the second item in the sub-arrays: import std.algorithm; void main() { auto arr = [[5,9],[5,3],[4,12],[7,8],[12,2],[5,8]]; schwartzSort!((e){ return e[1]; })(arr); assert(arr == [[12,2],[5,3],[7,8],[5,8],[5,9],[4,12]]); } To improve the usage of schwartzSort a support for transform function expressed as string may be added. For non-English speaking programmers the spelling of schwartzSort is not easy, and a so commonly used function may enjoy a shorter name any way, so a "keySort" name may be better ("key" refers to the key argument function of the Python sort, that's named "transform" in Phobos): import std.algorithm; void main() { auto arr = [[5,9],[5,3],[4,12],[7,8],[12,2],[5,8]]; keySort!q{a[1]}(arr); assert(arr == [[12,2],[5,3],[7,8],[5,8],[5,9],[4,12]]); } To help the understanding of this "keySort" name, in the signature of keySort the "transform" argument may be renamed "key". -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 21 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4909 See also: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=144557 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 16 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4909 Andrei Alexandrescu <andrei metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |andrei metalanguage.com AssignedTo|nobody puremagic.com |andrei metalanguage.com 09:07:36 PDT --- Omitting a string form for the transform is an oversight that should be fixed. Regarding naming, searching google etc. for schwartz sort yields relevant results whereas key sort does not. Please refrain from suggesting name changes of public APIs unless they add significant value. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 16 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4909Regarding naming, searching google etc. for schwartz sort yields relevant results whereas key sort does not.Schwartz sort is a common name and it's meaningful, but I am never able to remember its correct spell. Being it a very common operation (I use it about as often as the normal sort), I think it's better to rename it with a name that's simpler to remember (in spell) and maybe shorter too. Maybe Kagamin is not the only person that agrees on this. If you don't like keySort (I was just a quick idea), then we may search for something else, that possibly uses only short and easy to spell English words. Google is handy in many situations, but it's not the Alpha and Omega when you have to give names to things. "Schwart sort" gives 9,500 hits. "Decorate Sort Undecorate" gives 7,270 hits.Please refrain from suggesting name changes of public APIs unless they add significant value.Sorry, I'll keep suggesting what I think is better/right. Also, this enhancement request if from 2010-09, and I think I have said that schwartzSort is a bad name from the beginning, from the first time I have seen it. So it was not really a "name change". It's a name change now. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 16 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4909 10:20:10 PDT ---If you are using schwartzSort heavily, it makes sense to define a local alias for it. At any rate, you may be overstating your case; if you use something as frequently as you claim, you _will_ know the spelling.Regarding naming, searching google etc. for schwartz sort yields relevant results whereas key sort does not.Schwartz sort is a common name and it's meaningful, but I am never able to remember its correct spell. Being it a very common operation (I use it about as often as the normal sort), I think it's better to rename it with a name that's simpler to remember (in spell) and maybe shorter too. Maybe Kagamin is not the only person that agrees on this.If you don't like keySort (I was just a quick idea), then we may search for something else, that possibly uses only short and easy to spell English words.It's not about what I like or not. It's about doing sensible things. It doesn't seem sensible to simply decree that schwartzSort is inadequate to the extent it affects the productivity of people using it, and then solve the remaining problem of finding a different name for it.Google is handy in many situations, but it's not the Alpha and Omega when you have to give names to things. "Schwart sort" gives 9,500 hits. "Decorate Sort Undecorate" gives 7,270 hits.What would be the argument here? (That you unsubtly insert a typo, thus underlining how you can't remember the right spelling?)You are of course welcome to do so, but I'm just suggesting to invest energy in things that may actually improve the state of affairs. You are suggesting a change of name from a name that is easily searchable and memorable to a name that you haven't even found yet but are sure is better.Please refrain from suggesting name changes of public APIs unless they add significant value.Sorry, I'll keep suggesting what I think is better/right.Also, this enhancement request if from 2010-09, and I think I have said that schwartzSort is a bad name from the beginning, from the first time I have seen it. So it was not really a "name change". It's a name change now.The change didn't add value then, either. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 16 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4909(That you unsubtly insert a typo, thus underlining how you can't remember the right spelling?)I have not done that on purpose, I am sorry. But please trust me when I say I have problems with spelling that word :-) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 16 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4909 In Clojure language the sort with a key function is named "sort-by": http://clojuredocs.org/clojure_core/1.2.0/clojure.core/sort-by In Mathematica it is named "SortBy": http://reference.wolfram.com/mathematica/ref/SortBy.html In Scala it is named "sortBy": http://www.scala-lang.org/docu/files/collections-api/collections_5.html I suggest to deprecate "schwartzSort" name. In Phobos the "sortBy" name (as in Scala) will be better than "schwartzSort". -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 01 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4909 PDT --- https://github.com/D-Programming-Language/phobos/pull/1197 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4909https://github.com/D-Programming-Language/phobos/pull/1197The naming issue will have to wait.I still hate the "schwartzSort" name, after more than two years I am not able to remember its spelling. So I still think any other name will be better, like "keySort", "sortBy" or what else you prefer. (On the other hand to tell the truth nowadays I write that swartz name kind of randomly, compile the module, and dmd suggests me the right name, that I copy & paste (in 2010 there was no spelling corrector). So now the situation is bearable). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4909 Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/aeaf0cadeddce486337423e7c05ca73f703a8b50 Fix issue 4909 https://github.com/D-Programming-Language/phobos/commit/7cba78d5db6451de170f9d287fdbbfe25b47aaee Fix issue 4909 - Two suggestions for std.algorithm.schwartzSort() -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 23 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4909(On the other hand to tell the truth nowadays I write that swartz name kind of randomly, compile the module, and dmd suggests me the right name, that I copy & paste (in 2010 there was no spelling corrector). So now the situation is bearable).We are back to an unbearable situation, because currently with UFCS chains D doesn't give suggestions for wrong names: import std.algorithm; void main() { ["red", "yellow"].shwartzSort!q{ a.length }; } DMD 2.063beta5 gives: temp.d(3): Error: no property 'shwartzSort' for type 'string[]' So please rename that function name to something simpler. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 24 2013