Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to do???

2 views
Skip to first unread message

Dagan Elysee

unread,
Feb 24, 2002, 9:45:02 AM2/24/02
to
Please , can anyone tell me how to sort a a list of string  alphabetic?
 
How to sort a list of date by recent date to older date?
 
 
 
How can i make similar thing like "index"  in any help file?
i mean, when i type letter "C", the first word in the list with letter "C" is highlight with  blue color...
 
 
Thanks you

Randy Birch

unread,
Feb 24, 2002, 10:05:09 AM2/24/02
to
When you say "sort a list of strings" do you mean sort the string contents
of a listbox, or the contents of an string array?

--

Randy Birch
MVP Visual Basic

http://www.mvps.org/vbnet/

Please respond only to the newsgroups so all can benefit.

*** If you call the Sleep API in Bill's latest, will it have .NET dreams?
***


"Dagan Elysee" <dag...@sh.cvut.cz> wrote in message
news:uoyn4GUvBHA.1524@tkmsftngp02...

Hamed

unread,
Feb 24, 2002, 11:22:40 AM2/24/02
to
What you need is doable with a Combo box or a List box!
 
Hamed
Dagan Elysee <dag...@sh.cvut.cz> wrote in message news:uoyn4GUvBHA.1524@tkmsftngp02...

Dagan Elysee

unread,
Feb 24, 2002, 12:54:46 PM2/24/02
to

Does a listbox have a function to sort a list alphabetic? or by date?


Willy Van den Driessche

unread,
Feb 24, 2002, 7:17:14 PM2/24/02
to
For a heavy hammer solution :
http://users.skynet.be/wvdd2/Sorting/sorting.html

--
Van den Driessche Willy
For a work in progress :
http://users.skynet.be/wvdd2/index.html


"Dagan Elysee" <dag...@sh.cvut.cz> wrote in message

news:uXRX5wVvBHA.2632@tkmsftngp03...

Randy Birch

unread,
Feb 24, 2002, 7:25:21 PM2/24/02
to
Sort of (no pun intended). The listbox can be either sorted or unsorted.
This can not be changed at runtime. It will sort dates, but treats them as
strings.

Therefore, for a complete solution, your only options are:

- use external sorting code to unload / reload the list with the sorted
data. If there are only a couple of hundred items, this is instantaneous.
Sorting code can be found at :
http://www.mvps.org/vbnet/code/sort/index.html

- use a listview control instead, and use callbacks to perform a custom sort
... http://www.mvps.org/vbnet/code/callback/lvsortcallback.htm

--

Randy Birch
MVP Visual Basic

http://www.mvps.org/vbnet/

Please respond only to the newsgroups so all can benefit.

*** If you call the Sleep API in Bill's latest, will it have .NET dreams?
***


"Dagan Elysee" <dag...@sh.cvut.cz> wrote in message

news:uXRX5wVvBHA.2632@tkmsftngp03...

Joe "Nuke Me Xemu" Foster

unread,
Feb 24, 2002, 10:12:00 PM2/24/02
to
"Willy Van den Driessche" <Willy.Van.d...@skynet.be> wrote in message <news:OMKWDBZvBHA.212@tkmsftngp02>...

> For a heavy hammer solution :
> http://users.skynet.be/wvdd2/Sorting/sorting.html

Your cSortHeapSort is *miserable*! Modify SiftDown to take
both the lower and upper bounds, so that it can be used to
construct the heap in O(n) time. See Bentley's _Programming
Pearls_, section 14.6.2. (Are you certain you have actually
/read/ that book?)

Also, iSortableContainer may need an additional method, with a
typical implementation looking like this, to avoid extraneous
iSortableContainer_Item calls and the resulting Variant thrash,
when all you really wanted from those gyrations is -1, 0, or 1:

(And why are you flouting Commandment(0), "Thou shalt count all
things from zero"? You'd better clean up your act before the
Evangelists.NET find out about your back-sliding!)

Private Function iSortableContainer_Compare(ByVal nPos1 As Long, _
ByVal nPos2 As Long, ByVal Compare As iComparer) As Long

nPos1 = nPos1 - 1 + LBound(mArray)
nPos2 = nPos2 - 1 + LBound(mArray)

iSortableContainerCompare = Compare.Compare(mArray(nPos1), mArray(nPos2))
End Sub

Of course, you might also want iComparer.Compare to take its
parameters ByRef instead of ByVal, if implementations can be
trusted to not stomp their arguments, which your current
interface allows on object types anyway:

Function Compare(ByRef Value1 As Variant, ByRef Value2 As Variant) As Long

After that, it might finally make sense to modify cSortQuickSort
and cSortQuickSortNonObject to avoid both the quadratic behavior
and the ultra-naïve boundary checking within the "hottest" loops:

URL:http://groups.google.com/groups?selm=u4etsq9jcc5721%40corp.supernews.com


PS: WTF is the deal with VarAssign?

URL:http://users.skynet.be/wvdd2/General_techniques/Let_and_Set/let_and_set.html

Does VarSource /really/ need to be ByVal too? And have you ever
actually seen a Variant for which IsEmpty() and IsObject() both
return True, or was this some kind of brain-dead kludge around a
dain-bramaged class' default value property gone horribly wrong?


PPS: Do you still insist that an in-place O(n) sort is totally
impossible, even in C, C++ STL, Delphi, Modula-II, Java, or .NET?
So just claim your fame and amaze us by disproving any possible
general-purpose sorting component that guarantees O(n) performance.
Be sure to <rot13>SBNQ</rot13> when you're done.

URL:http://staff.cs.utu.fi/~tpasanen/Pubs_of_Tomi_Pasanen.html

--
Joe Foster <mailto:jlfoster%40znet.com> L. Ron Dullard <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above They're coming to
because my cats have apparently learned to type. take me away, ha ha!


Randy Birch

unread,
Feb 24, 2002, 10:43:35 PM2/24/02
to
Joe ..

But other than that, you liked it, right? <vbg>

--

Randy Birch
MVP Visual Basic

http://www.mvps.org/vbnet/

Please respond only to the newsgroups so all can benefit.

*** If you call the Sleep API in Bill's latest, will it have .NET dreams?
***


"Joe "Nuke Me Xemu" Foster" <j...@bftsi0.UUCP> wrote in message
news:#M0XIpavBHA.2612@tkmsftngp03...

> and the ultra-naďve boundary checking within the "hottest" loops:

Joe "Nuke Me Xemu" Foster

unread,
Feb 25, 2002, 11:52:07 PM2/25/02
to
"Randy Birch" <r...@mvps.org> wrote in message <news:ucpGB6avBHA.2644@tkmsftngp07>...

> Joe ..
>
> But other than that, you liked it, right? <vbg>

Certainly! It's good for /hours/ of wholesome family entertainment...

--
Joe Foster <mailto:jlfoster%40znet.com> DC8s in Spaace: <http://www.xenu.net/>

Willy Van den Driessche

unread,
Feb 26, 2002, 5:50:16 PM2/26/02
to
Ok Joe,

You took the time to analyze my code so I should at least take the time to
investigate your comments. You must realize that you have a way of putting
things that offends a lot of people. I have seen people make statements in
the newsgroups about never wanting to reply on any of your posts. I can't
honestly see how insulting people can help a discussion. This being said, I
want a clean and honest discussion.

1. cSortHeapSort
As far as I can recall, this code is an exact transcript from Bentleys book.
I honestly don't see what you menad by 'passing the upper and lower bounds'.
Please explain.

2. ISortableContainer
This interface is asymmetric (has an item get put not a set/let). You know
the reason for this is to have a cSortablePermutation, which allows you to
"create and index" on a "sortableContainer", while leaving the original
untouched. For the purposes I have, I think ISortableContainer is minimal.
It is minimal in the sense that I didn't put extra methods or properties in
to ease any other future implementations.
I don't think I get the point of the '-1, 0, 1' stuff. What's a gyration ?
( I 'm Flemish speaking)

3. Variants
I'm not quite fond of using variants myself. But I don't think I can write
a sorting routine that claims to be able to sort anything without them. I
guess in VB variant comes closest to *anything*.

4. ByRef - ByVal
I want my code to reflect the purpose of the parameter. It is clear that
semantically the parameters of an IComparer should be ByVal. You are not
allowed to change the parameters in something that is supposed just to
compare them. I know that ByRef gives better performance. Maybe you're
right an it would be a good idea in this particular case.

5. the QuickSort.
The quicksort actually comes from a Delphi Demo Program I found. I know
there are variations and even variations that make QuickSort stable.
However, ISortAlgorithm is an interface so any other implementation is
welcomed. I will incorporate you variation but it will take time (I'm
building two additional rooms upstairs and there's a baby coming soon).

6. VarAssign
The Byval is the same as always. It could always be byRef. I never really
looked at the IsEmpty stuff. I certainly didn't think about default
properties there. Now that I see it again, I think the IsEmpty stuff is
redundant.

7. O(n) sorting
I'm not claiming there are no O(n) sorting algorithms. I'm just claiming
they demand special knowledge about the items to be sorted. These items
generally need some "bound integer-ness". If a general-purpose O(n) sorting
algorithm were available, why then would they not implement it in all the
recent frameworks ?


--
Van den Driessche Willy
For a work in progress :
http://users.skynet.be/wvdd2/index.html

"Joe "Nuke Me Xemu" Foster" <j...@bftsi0.UUCP> wrote in message

news:eeHt3PovBHA.2592@tkmsftngp04...

Klaus H. Probst

unread,
Feb 26, 2002, 10:49:40 PM2/26/02
to
Willy,

Ignore Joe. He's just being Joe. He thinks we're all scientologists out to
get him.

Joe is actually an AI experiment run by Microsoft and let loose on the
servers. He's here to keep us entertained (and on our toes sometimes).

____________
Klaus

"Willy Van den Driessche" <Willy.Van.d...@skynet.be> wrote in

message news:ObiduZxvBHA.2692@tkmsftngp07...

dnagel

unread,
Feb 27, 2002, 11:35:55 AM2/27/02
to
ROTFL!

D.

"Klaus H. Probst" <kprobst@v b b o x.com> wrote in message
news:#57QSG0vBHA.2636@tkmsftngp07...

Joe "Nuke Me Xemu" Foster

unread,
Feb 27, 2002, 3:07:57 PM2/27/02
to
"Klaus H. Probst" <kprobst@v b b o x.com> wrote in message <news:#57QSG0vBHA.2636@tkmsftngp07>...

> Ignore Joe. He's just being Joe. He thinks we're all scientologists out to
> get him.

I've got a tinfoil hat, and I'm gonna use it.

http://tinfoilhat.cultists.net/faq.html

http://tinfoilhat.cultists.net/readme.txt

> Joe is actually an AI experiment run by Microsoft and let loose on the
> servers. He's here to keep us entertained (and on our toes sometimes).

Embrace and extend this, d00d!

http://megahal.net/Aliens.html

http://megahal.net/Best.html

Klaus H. Probst

unread,
Feb 28, 2002, 1:50:04 AM2/28/02
to

"Joe "Nuke Me Xemu" Foster" <j...@bftsi0.UUCP> wrote in message
news:#m91pp8vBHA.2692@tkmsftngp07...

> "Klaus H. Probst" <kprobst@v b b o x.com> wrote in message
<news:#57QSG0vBHA.2636@tkmsftngp07>...
> > Joe is actually an AI experiment run by Microsoft and let loose on the
> > servers. He's here to keep us entertained (and on our toes sometimes).
>
> Embrace and extend this, d00d!
>
> http://megahal.net/Aliens.html
>
> http://megahal.net/Best.html

Oh, you're *far* better than that, Joe =)

____________
Klaus


Joe "Nuke Me Xemu" Foster

unread,
Mar 1, 2002, 4:39:59 PM3/1/02
to
"Willy Van den Driessche" <Willy.Van.d...@skynet.be> wrote in message <news:ObiduZxvBHA.2692@tkmsftngp07>...

> You took the time to analyze my code so I should at least take the time to
> investigate your comments. You must realize that you have a way of putting
> things that offends a lot of people. I have seen people make statements in
> the newsgroups about never wanting to reply on any of your posts. I can't
> honestly see how insulting people can help a discussion. This being said, I
> want a clean and honest discussion.

That is not consistent with your "point" 1.

> 1. cSortHeapSort
> As far as I can recall, this code is an exact transcript from Bentleys book.
> I honestly don't see what you menad by 'passing the upper and lower bounds'.
> Please explain.

Stop being disingenuous -- I told you *exactly* where to look
within Bentley's _Programming Pearls_, in section 14.6.2:

----
Modify /siftdown/ to have the following specification.

void siftdown(l, u)
pre heap(l+1, u)
post heap(l, u)

What is the run time of the code? Show how it can be used to construct an /n/-
element heap in /O(n)/ time and thereby a faster Heapsort that also uses less code.
----

Well?

> 2. ISortableContainer
> This interface is asymmetric (has an item get put not a set/let). You know
> the reason for this is to have a cSortablePermutation, which allows you to
> "create and index" on a "sortableContainer", while leaving the original
> untouched. For the purposes I have, I think ISortableContainer is minimal.
> It is minimal in the sense that I didn't put extra methods or properties in
> to ease any other future implementations.

They have methods to swap elements, so why not to compare too?

> I don't think I get the point of the '-1, 0, 1' stuff. What's a gyration ?
> ( I 'm Flemish speaking)

Your current interfaces require an excessive amount of work to
be done in order to compare the elements. Instead of fetching
(copying) the elements from the container and passing (copying)
them into the comparer, you could tell the container to compare
two of its elements using the comparer. Since these containers
are supposed to be *sortable* containers, is it not appropriate
for them actually to have a little extra support for *sorting*?

> 3. Variants
> I'm not quite fond of using variants myself. But I don't think I can write
> a sorting routine that claims to be able to sort anything without them. I
> guess in VB variant comes closest to *anything*.

Yes, you have little choice but to use Variant, but passing them
around ByVal is rather expensive.

> 4. ByRef - ByVal
> I want my code to reflect the purpose of the parameter. It is clear that
> semantically the parameters of an IComparer should be ByVal. You are not
> allowed to change the parameters in something that is supposed just to
> compare them. I know that ByRef gives better performance. Maybe you're
> right an it would be a good idea in this particular case.

Perhaps in addition to ByRef and ByVal, there should have been
ByConst, which could always Do The Right Thing for performance,
since the subroutine must pretend it's just a Const. (What are
the implications for object references?) Oh well, it's all too
late now, isn't it!

> 5. the QuickSort.
> The quicksort actually comes from a Delphi Demo Program I found. I know
> there are variations and even variations that make QuickSort stable.

Yes, there are a number of ways to build stable partitions.

> However, ISortAlgorithm is an interface so any other implementation is
> welcomed. I will incorporate you variation but it will take time (I'm
> building two additional rooms upstairs and there's a baby coming soon).

You all should get all the sleep and rest you can now, because
you'll soon be chronically sleep-deprived for the next couple of
decades. Welcome to zombie-land.

> 6. VarAssign
> The Byval is the same as always. It could always be byRef. I never really
> looked at the IsEmpty stuff. I certainly didn't think about default
> properties there. Now that I see it again, I think the IsEmpty stuff is
> redundant.

It is much worse than merely "redundant"! What would happen if
varSource is an object reference whose default property just so
happens to return Empty at that time?

> 7. O(n) sorting
> I'm not claiming there are no O(n) sorting algorithms. I'm just claiming
> they demand special knowledge about the items to be sorted. These items
> generally need some "bound integer-ness". If a general-purpose O(n) sorting
> algorithm were available, why then would they not implement it in all the
> recent frameworks ?

Perhaps because Anders "VBK" Hejlsberg and other faddies are more
concerned with Pure OOP than with actual programming? Anyway, a
framework with some extensions to the usual serialization support
could make good use of radix sorting:

URL:http://gsp.com/cgi-bin/man.cgi?section=3&topic=radixsort

URL:http://nb.net/~lbudney/linux/software/rsort.html

However, here may be a way to incorporate radix-sorting into the
existing standard C++ STL "framework":

URL:http://groups.google.com/groups?selm=7dc3b1ea.0105220447.2edc7c07%40posting.google.com

I suggest you not lose sleep over it now -- you cannot afford to.

--
Joe Foster <mailto:jlfoster%40znet.com> Sign the Check! <http://www.xenu.net/>

0 new messages