[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [office] Proposal for Spreadsheets: New sort option "natural sort"
On Friday 02 February 2007, Michael Brauer - Sun Germany - ham02 - Hamburg wrote: > Step 4. In this step, the numeric substring is determined by locating > the first occurrence of a non-digit character after the first digit > character; the substring from the first digit character through the > character preceding the first non-digit is considered the numeric > substring. This substring is then converted into a double-precision > variable. This step is performed on both of the compared strings, and > the converted values are compared by simple numeric comparison. If these > values differ, then the result will be returned and the process will > end. If they are equal to one another, then the process will proceed to > the next step. Here's a comment by Martin Pool, who implemented "natural sorting" in KDE. " If I'm reading this correctly, that means that "1.3" > "1.20", in a locale where "." is the decimal separator. In typical software version strings that's not correct, and that was the case I was originally trying to handle, and also apparently the case Robert Weir describes. Obviously sometimes sorting as floats is best but I suggest that when numbers are intermixed with non-digits the other algorithm is better. That is, to basically follow this algorithm but just treat the decimal separator as non-numeric. Also, conversion to double might give unexpected results if there are very long runs of digits (barcodes?) I'm not sure if that is a concern. Also it seems rather odd that 1.2.3.4 will be sorted as (1.2, 3.4)... " -- David Faure, faure@kde.org, sponsored by Trolltech to work on KDE, Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]