We help IT Professionals succeed at work.
Get Started

Smalltalk collections list to array

Last Modified: 2012-05-07
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

Watch Question
Java Developer
Top Expert 2010
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE