troubleshooting Question

Smalltalk collections list to array

Avatar of ubuntuguy
ubuntuguyFlag for United States of America asked on
Programming Languages-OtherJavaC
1 Comment1 Solution310 ViewsLast Modified:
I have a list of employee objects in smalltalk. I'm trying to perform selection sort on this list to sort it by last name (lastName). Can you guide me in the right direction? I don't think I'm doing it right. This is how I create my method: I think I'm right since I dont get any errors... I just don't know how implement it to sort my list of employees by last name.
selectionSort: l to: r
| m il ir temp |
   (r > l) ifTrue: [
      m := self at: ((l + r) // 2).
      il := l.
      ir := r.
         [(self at: il) < m] whileTrue: [il := il + 1.].
         [(self at: ir) > m] whileTrue: [ir := ir - 1.].
         (il < ir) ifTrue: [
            " swap "
            temp := self at: il.
            self at: il put: (self at: ir).
            self at: ir put: temp.
      ] doUntil: [il >= ir.].
      self selectionSort: l to: (il - 1).
      self selectionSort: (il + 1) to: r.

Open in new window

Mick Barry
Java Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2010

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros