RE: [sqlite] How to sort not binary?
Since you use C# (mentioned in a different message) you can easily write a custom collation function with SQLite.NET. http://sqlite.phxsoftware.com/ Look in the help for SQLiteFunction and particularly FunctionType.Collation. HTH, Sam --- We're Hiring! Seeking a passionate developer to join our team building products. Position is in the Washington D.C. metro area. If interested contact [EMAIL PROTECTED] -Original Message- From: Yves Goergen [mailto:[EMAIL PROTECTED] Sent: Saturday, May 12, 2007 11:24 AM To: sqlite-users@sqlite.org Subject: [sqlite] How to sort not binary? Hi, I'm trying to get my table sorted the way how for example Windows Explorer or other file managers are sorting names. Most of all, accented characters should not be listed at the end of the list but near their non-accented character instead. I can only see the built-in collations BINARY and NOCASE. Is there something else? -- Yves Goergen "LonelyPixel" <[EMAIL PROTECTED]> Visit my web laboratory at http://beta.unclassified.de - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] How to sort not binary?
On 25.06.2007 00:57 CE(S)T, [EMAIL PROTECTED] wrote: > Yves Goergen <[EMAIL PROTECTED]> wrote: >> Oh, well, I just realised that this will only sort numbers "naturally" >> at the beginning of strings, but not in the middle or at the end. It >> will be a bit more complex to do that. Maybe I find a sort/compare >> algorithm for it. But at least I know now that it's easy to use. :) > Check out the "sortStrCmp()" function in older versions of > SQLite version 2 in the util.c source file. See, for example, > >http://www.sqlite.org/cvstrac/fileview?f=sqlite/src/util.c=1.42 > > I think the sortStrCmp() function does what you are after. Okay, first thank you for pointing me on this. But even with the good documentation about the state machine implemented, this surely is highly optimised C "hack"* code that I probably won't understand so soon. Another problem is that I can't easily translate this into C# because there's no such thing as pointers to strings (character arrays). I'll keep on searching for a function for that. Maybe, given enough time, I'll come up with my own one... Some day... ;-) *) I mean, come on, using negative array indices on pointers... cb = b[-1]; ;-) -- Yves Goergen "LonelyPixel" <[EMAIL PROTECTED]> Visit my web laboratory at http://beta.unclassified.de - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] How to sort not binary?
Yves Goergen <[EMAIL PROTECTED]> wrote: > On 22.06.2007 17:48 CE(S)T, Yves Goergen wrote: > > Match m1 = Regex.Match(param1, "^([0-9]+)"); > > if (m1.Success) > > { > > Match m2 = Regex.Match(param2, "^([0-9]+)"); > > if (m2.Success) > > { > > int cmpNum = int.Parse(m1.Groups[1].Value) - > > int.Parse(m2.Groups[1].Value); > > if (cmpNum != 0) return cmpNum; > > } > > } > > return String.Compare(param1, param2, true); > > Oh, well, I just realised that this will only sort numbers "naturally" > at the beginning of strings, but not in the middle or at the end. It > will be a bit more complex to do that. Maybe I find a sort/compare > algorithm for it. But at least I know now that it's easy to use. :) > Check out the "sortStrCmp()" function in older versions of SQLite version 2 in the util.c source file. See, for example, http://www.sqlite.org/cvstrac/fileview?f=sqlite/src/util.c=1.42 I think the sortStrCmp() function does what you are after. -- D. Richard Hipp <[EMAIL PROTECTED]> - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] How to sort not binary?
Hi, I'm trying to get my table sorted the way how for example Windows Explorer or other file managers are sorting names. Most of all, accented characters should not be listed at the end of the list but near their non-accented character instead. I can only see the built-in collations BINARY and NOCASE. Is there something else? -- Yves Goergen "LonelyPixel" <[EMAIL PROTECTED]> Visit my web laboratory at http://beta.unclassified.de - To unsubscribe, send email to [EMAIL PROTECTED] -