Talk:Sort the letters of string in alphabetical order: Difference between revisions

 
(7 intermediate revisions by 3 users not shown)
Line 79:
:# But... when you say <i>it would be helpful to specify what to do with any characters encountered that ''aren't'' in the input string</i> -- what do you mean? If the characters are not in the input string, how would they be encountered??
:--[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 19:32, 12 August 2022 (UTC)
 
::Maybe I'm just reading too strictly, but the wording of the task encourages my confusion..
::# As I read it, it asks for characters "natural to the language". ASCII is certainly not "natural", EBCDIC perhaps even less-so. Both are machine constructs, not language constructs, so it seemed to me like the task-writer might have had something else in mind.
::# If this is just another pointless variation of "rewrite a sort algorithm" then still same request: please clarify/formalize the specification, provide an example, etc. There are hints that the task-writer might have been attempting to convey the use of a natural-language-specific collated sort.
::# It's a question of domain, and how to handle values outside the domain. Let's assume the task-author agrees to provide sample input/output strings in order to demonstrate the intended collation sequence, but still allows implementations to choose their OWN input strings, natural to their language (as is currently the case). If, hypothetically, the task-author failed to include/demonstrate the sorting of punctuation, then how should an implementation handle punctuation characters if encountered? Either that, or require the use of the example input, and accept only the example output. (eliminating free choice input entirely, so that the domain of characters is predetermined)
::If the task-writer merely wants characters of a string sorted by whatever machine-collation (whether ASCII, EBCDIC or other) happens to be in effect, then I'd recommend the task be written in simpler terms, so as not to suggest that something more might have been intended. --[[User:Davbol|Davbol]] ([[User talk:Davbol|talk]]) 05:38, 13 August 2022 (UTC)
 
::: Indeed "natural to the language" and the most typical meaning for "natural" represent very different concepts (and rely on different "natural language" definitions of the adjective).
::: But perhaps you could suggest a better phrasing which you think would serve here? --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 07:53, 13 August 2022 (UTC)
 
:::: The task says "A character for this purpose should be whatever is natural for your language" - surely, this means the programming language, not the programmer's natural language. The collating sequence is thus defined by the character set being used - ASCII, Unicode, EBCDIC or whatever. Most languages have a character/byte/rune/whatever type and so the task author is saying use whatever's best for the language.
:::: Perhaps the wording could be changed to "A character for this purpose should be whatever is natural for your programming language".
:::: Mandating the collating sequence would disadvantage languages where the specified sequence wasn't the one "natural" to the programming language and surely over-complicate the code. The task is a simple sorting application, requiring demonstration of how to get at the individual characters of a string.--[[User:Tigerofdarkness|Tigerofdarkness]] ([[User talk:Tigerofdarkness|talk]]) 08:59, 13 August 2022 (UTC)
 
:::::So it'd be ok if "N" comes before "a"? In ASCII it does, alphabetically it does not. Even case-insensitive, it still isn't specified which of e.g. "nN" or "Nn" would be correct. If the tasks indeed just wants a simple ASCII sort then it should just come out and say so - all of the extraneous language in the task description does NOT clarify that. If the task is merely to demonstrate individual character retrieval, then there are simpler ways to demonstrate (e.g, just count the chars, or reverse the string, etc) without opening up the can-of-worms of lexicographical order. If the task has something ''else'' in mind, then it fails to convey it adequately. --[[User:Davbol|Davbol]] ([[User talk:Davbol|talk]]) 18:10, 15 August 2022 (UTC)
:::::: My reading of the task is that ASCII order is *acceptable* but not *required*. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 19:44, 15 August 2022 (UTC)
 
:::::: I agree - looking at the existing samples, it would seem that almost all of them have N before a, a small number have a before A, so the "acceptable but not required" interpretion seems good to me. I see your Lua sample is one of the exceptions, which is fine. I don't think making 99% of the others invalid is worth it. --[[User:Tigerofdarkness|Tigerofdarkness]] ([[User talk:Tigerofdarkness|talk]]) 20:22, 15 August 2022 (UTC)
 
:::::: Incidently, the task was written by Calmosoft, the author of the Ring sample, which appears to specifically use ASCII and removes spaces. It has only lowercase and spaces in the sample string. --[[User:Tigerofdarkness|Tigerofdarkness]] ([[User talk:Tigerofdarkness|talk]]) 20:37, 15 August 2022 (UTC)
3,021

edits