Minggu, 09 Oktober 2011

[ExcelVBA] Re: Binary Search Problem

 

I made a effort to present my sort results in carefully aligned columns, but I see in the email I received that the columns were destroyed. My point, which might still be visible, is that sort order and ASCII value order do not agree, and I don't know why. If Excel is not using ASCII values to sort, what is it using?

--- In ExcelVBA@yahoogroups.com, "mickey11030" <mickey11030@...> wrote:
>
> This is somewhat off topic, but since we're talking about sorting, I
> thought I'd bring up unexpected behavior I noticed some time ago. I
> sorted special characters on the Character column and got these results:
> Name Character ASCII apostrophe '
> 39 dash - 45 space
> 32 exclamation ! 33 quote "
> 34 pound # 35 dollar
> $ 36 percent % 37
> ampersand & 38 open paren (
> 40 close paren ) 41 asterisk *
> 42 comma , 44 period
> . 46 slash /
> 47 plus + 43
> I assumed Excel sorted according to ASCII values, but you'll notice that
> the apostrophe, ASCII value 39 and dash, ASCII value 45 sort before the
> space, ASCII value 32, and that plus, ASCII value 43, sorts after slash,
> ASCII value 47. Does anyone know what's going on?
> --- In ExcelVBA@yahoogroups.com, PY & Associates <pynasocas@> wrote:
> >
> > Enlightening.
> >
> > I modified two lines thus
> > If not (Dict_SD.exists(UCase(Sheet1.Cells(x, 1).Value))) Then
> > Sheet1.Cells(x, 4).Value = "Y"
> > If not (Dict_PH.exists(ucase(Sheet1.Cells(x, 1).Value))) Then
> > Sheet1.Cells(x, 5).Value = "Y"
> >
> > Regards
> > KC@103
> > pynasocas
> >
> > From: Paul Schreiner schreiner_paul@
> > To: ExcelVBA@yahoogroups.com
> > Sent: Friday, 7 October 2011 8:56 PM
> > Subject: Re: [ExcelVBA] Binary Search Problem
> >
> >
> >
> > #2.. You're using an Interval Halving technique for searching the
> list.
> > However, for it to work properly, the data has to be sorted correctly.
> >
> > Unfortunately, it doesn't look like it's sorting properly.
> > Specifically,
> > the ASCII code for "-" is 45
> > the ASCII code for "0" is 48
> > (1-9 are codes 49-57)
> >
> > But in the sort, "-" is sorted AFTER numbers.
> > (see rows:
> > 6115: 020-SUB-0011
> > 6116: 02-16917-3600
> >
> > 12513: 400-TUNECVR-0003
> > 12514: 40-26314
> > )
> >
> > for that reason, when the interval happens to test lines comparing 020
> to 02-,
> > it assumes that the 020 should be AFTER 02-, but the next iteration
> finds that
> > it is outside the range,
> > and therefore assumes it cannot find it.
> > I'm not sure what can be done about this sorting problem, however, I
> have an
> > alternate solution.
> >
> > Paul
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
> [Non-text portions of this message have been removed]
>

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar