czardas Posted March 2, 2016 Share Posted March 2, 2016 (edited) Beyond the fact that mixed data types exist, and some have the desire to keep everything tidy; when do you really need to do an alpha-numeric sort? Isn't using one sorting method adequate in most situations? I know it's intended to be dual purpose, but that's not an answer to my question. Edited March 2, 2016 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
BrewManNH Posted March 3, 2016 Share Posted March 3, 2016 You would use an alphanumeric sort when you want things sorted alphanumerically. Numbers sorted in ascending/descending order and then text sorted alphabetically. Lexicographical order would be if you want your strings/numbers sorted in ASCII order, 100 would come before 5 and after 10, and this isn't what most people would want them to be sorted to. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
TheSaint Posted March 3, 2016 Share Posted March 3, 2016 What is this related to, as I am not understanding the question? Wouldn't alphanumeric be the sensible default anyway, in most cases. Perhaps a real world example would make things clearer. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
czardas Posted March 3, 2016 Author Share Posted March 3, 2016 (edited) 4 hours ago, BrewManNH said: You would use an alphanumeric sort when you want things sorted alphanumerically. Numbers sorted in ascending/descending order and then text sorted alphabetically. Lexicographical order would be if you want your strings/numbers sorted in ASCII order, 100 would come before 5 and after 10, and this isn't what most people would want them to be sorted to. When do you want things sorted alpha-numerically and why? You are just saying people have the desire to have things sorted this way. I want a real reason: not some fad or fancy. 2 hours ago, TheSaint said: Perhaps a real world example would make things clearer. It is related to functional sorting algorithms. You give a real world example of where alpha-numeric sort is useful, because I can't think of one. plz Edited March 3, 2016 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
TheSaint Posted March 3, 2016 Share Posted March 3, 2016 3 minutes ago, czardas said: You give a real world example of where it is useful, because I can't think of one. plz Well, you haven't given me any parameters ... so no context. However, in a generic way, what about band names. They can be comprised of the three main states (mixed, alpha, numeric) and they belong to the same group - band names. So how would you sort them, if not alphanumerically? It is useful to have a specific order, if just for look up purposes. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
czardas Posted March 3, 2016 Author Share Posted March 3, 2016 (edited) Any context or parameters you choose. I would sort band names alphabetically (lexicographically) because they are names. There might be a really big band in the mix, but magnitude has no bearing on the name. Edited March 3, 2016 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
TheSaint Posted March 3, 2016 Share Posted March 3, 2016 So you have given it the parameter of names ... string in effect. A string however, as you know, can be comprised of alphabetical characters as well as numerical ones. So a band named 100 doesn't fall inside alphabetical. Where would they be sorted to? Would there be a conversion to the alphabetical text of "one hundred" and so sort under the alpha character 'o' Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
czardas Posted March 3, 2016 Author Share Posted March 3, 2016 (edited) Well it's probably simplest to take the easiest path and use StringCompare() to test equality: lexicographically placing numbers before letters. However as you say, this is not the only possible way to arrange such a mixed group. BTW, you mentioned band names: not me. I said any context. Band names do not constitute justification for an alpha-numeric sorting algorithm because numeric band names have nothing to do with a band's magnitude. To me, numeric sorting applies to magnitude and not to the position of characters within some code page. I am of the opinion that alpha-numeric sorting is nothing more than a dual purpose algorithm with no real world application beyond this fact. Please prove me wrong if you can. I'm writing a sorting function and it already has 2, or possibly 3, algorithms: alphabetical, numeric and string length. Edited March 3, 2016 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
TheSaint Posted March 3, 2016 Share Posted March 3, 2016 (edited) Taken from - https://en.wikipedia.org/wiki/Lexicographical_order Quote A lexicographical ordering may not coincide with conventional alphabetical ordering. For example, the numerical order of Unicode codepoints does not always correspond to traditional alphabetic orderings of the characters, which vary from language to language. So the lexicographic ordering induced by codepoint value sorts strings in an unambiguous canonical order, but it does not necessarily "alphabetize" them in the conventional sense. Perhaps that helps? Me, I continue to struggle with the notion, that numbers can be alphabetical in their numeric state. It seems like an oxymoron to me. To me, the numbers should be ignored or placed at start or end, without sorting ... for the sorting would require being numerical, not alphabetical. Edited March 3, 2016 by TheSaint czardas 1 Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
czardas Posted March 3, 2016 Author Share Posted March 3, 2016 (edited) Good, I think we are getting somewhere now. The two sorting methods are incompatible. Numeric sorting should not necessarily care about data type, and alphabetic sorting applied to a mixture of alpha-numeric characters should ignore numeric magnitude. Keeping the algorithms separate avoids having to make some dubious decisions. Edit : Sorting strings numerically has some excellent benefits. Firstly, the main benefit is that you don't (necessarily) have to corrupt data (formatting) by converting strings to numbers prior to sorting; and secondly, numeric size can be totally unlimited (well beyond the maximum, non-infinite, double). Theoretically, numeric strings can become as large as ~10^2147483646 in AutoIt. Although I don't intend to test these bounds, suffice it to say that it's pretty humongous. Edited March 3, 2016 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
czardas Posted March 3, 2016 Author Share Posted March 3, 2016 (edited) Here are the options I currently have planned for my function. I intend to use a binary flag with the following possible values. It seems unnecessary to include an alphanumeric sorting algorithm as well. I can't think of any application for it. 0 - alphabetical / lexical [applies to all items including numbers] 1 - descending [applies to sorted items] 2 - numeric [applies to numbers and decimal strings only ==> overrides flag 0] 4 - string length [applies to all items ==> overrides flags 0 & 2] Any comments? Edited March 3, 2016 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
BrewManNH Posted March 3, 2016 Share Posted March 3, 2016 Here is a real world example of why you'd want to sort alphanumerically, You have a list of addresses, houses numbered 1 through 1000, you want to drop off deliveries to each house, and you mark each one off as you drop it off. Would you want to search past 100 to find house #2, then go back and search past 200 to get to house #3? You'd want them in numerical order because that is how the real world is sorted. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
czardas Posted March 3, 2016 Author Share Posted March 3, 2016 (edited) Hmm, _ArraySort() currently can't do that. There is no such thing as a half-number/half-string data type. You need to add zero padding, or something to that effect. I appreciate you having a think about it, that was a clever answer even though I rejected it. Edited March 3, 2016 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
BrewManNH Posted March 3, 2016 Share Posted March 3, 2016 Currently can't do what? Look at _VersionCompare which uses both a lexicographical and an alphanumeric comparison of version strings depending on the contents of the version string. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
czardas Posted March 3, 2016 Author Share Posted March 3, 2016 (edited) That's a very specific function. How do I know whether my half-string/half-number is a file version (delimited string), an English date (delimited string), a house number followed by a street name. _ArraySort() cannot currently do these things which you mention. It seems we mean two different things by alphanumeric sorting. I mean a dual purpose sorting algorithm which behaves in the same way as, or in a similar way to, _ArraySort() in Array.au3. There are a zillion possible specific circumstances where sorting involves complex pre-processing. Should I include all words pertaining to magnitude of some type or other (eg September, nautical mile) within all languages, past or present? It's not really practical to have a sorting algorithm which is longer than the Britannica and takes weeks to run all checks. Edited March 3, 2016 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
jchd Posted March 4, 2016 Share Posted March 4, 2016 The so-called "natural sort" is pretty useful in many contexts. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
czardas Posted March 4, 2016 Author Share Posted March 4, 2016 Thanks, I'll look at that. I am not sure if I should include string length, because it's probably less useful. I have been playing around with it, but progress is slow - multiple projects on the go at the same time. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
czardas Posted March 4, 2016 Author Share Posted March 4, 2016 Natural sort looks to be a bit of a monster routine CPU eater. I see how it can be useful. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
czardas Posted March 13, 2016 Author Share Posted March 13, 2016 (edited) I decided to include alphanumeric sort because people are used to it and I didn't want to raise too many eyebrows. I decided to exclude natural sort (for now at least), because I think it's only useful for badly designed systems, or those which have no clear design at all. I like the idea, but I intend focus my attention on highly organized data: numbers or strings preferably in separate containers. It's faster and cleaner, but less useful if you have strange mixed alphanumeric formatting which slows everything down. I feel that having so many numeric data types is complicated enough already. You can find the results in ArrayWorkshop. This sort function turned out to be one of the more challenging functions I have written. Edited March 13, 2016 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now