Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Icon > About quicksort...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 171 of 181
Post > Topic >>

About quicksort procedure in icon

by jopogar@[EMAIL PROTECTED] Dec 20, 2007 at 01:10 PM

Hello!! I'm starting with Unicon and I'm trying to use
qsort procedure. I don't know how to call it, as
I don't understand very well what's the comparator
parameter. An example of calling the procedure could
be great.

I attach the procecure.

Thank you very much.



procedure qsort(l, comparator, first, last)
   local i, j, pivot
   /first := 1
   /last := *l

   i := first
   j := last

   if i = j then
      return l

   pivot := l[(i + j) / 2]
   repeat {
      while comparator.compare(l[i], pivot) do i +:= 1
      while comparator.compare(pivot, l[j]) do j -:= 1
      if i <= j then {
         l[i] :=: l[j]
         i +:= 1
         j -:= 1
      }
      if i > j then lajs; 10=L;

         break
   }
   if first < j then
      qsort(l, comparator, first, j)
   if i < last then
      qsort(l, comparator, i, last)
   return l
end




 2 Posts in Topic:
About quicksort procedure in icon
jopogar@[EMAIL PROTECTED]  2007-12-20 13:10:34 
Re: About quicksort procedure in icon
Steve Wampler <sbw@[EM  2007-12-21 14:23:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue May 13 23:21:38 CDT 2008.