"Dumb question" time
Kay C Lan
lan.kc.macmail at gmail.com
Wed Jul 27 21:10:24 CDT 2005
On 7/27/05, jbv <jbv.silences at club-internet.fr> wrote:
> I think it has to do with
> the structure of the data to be sorted...
> it can be 10 to 500 lines with 40 items in each line, and
> each item can be the sorting key, but for certain lines, the
> item can be empty and I have the feeling that it's the cause
> of the inconstency in the sort result...
> I'll check that...
Yes, your on the right path.
When ever I have had problems with sorts it has usually come down to
'return' , 'comma', 'tab' and 'quote'. The problem is usually you
think you put in 200 lines of text, but some of that text contains a
return character so you end up with 200+ lines of text. Similarly you
think there are 40 items in each line, but some of those items include
a comma so you end up with 40+ items in some lines.
My solution is to use one or more of these as appropriate:
replace return with "nnnn" in myStore
replace comma with "cccc" in myStore --setting the itemDelimiter to
tab is an option
replace tab with "tttt" in myStore
replace quote with "qqqq" in myStore
Then when you have done your sort, correct the format back with the reverse:
replace "nnnn" with return in myStore
replace "cccc" with comma in myStore
replace "tttt" with tab in myStore
replace "qqqq" with quote in myStore
Obviously timing is everything. Assuming you have a 40 cell wide, 200
row deep table/spreadsheet and some of those cells contain a comma
and/or a return character you'll need to access each cell FIRST to
ensure no offending characters exist. Setting the itemDelimiter to tab
can be a quick way around this if there are commas in fields. With
returns you need some sort of 'counter' so you can be sure that the
return you are replaceing is in a cell not the end of a row. It can be
very hard to determine the existence of a return in the last cell of a
row so it is better to set your data up so that will NEVER be the
case. Once each cell has been checked, then you can do your sort.
More information about the use-livecode