Thanks Robert, that's a good explanation. In fact I didn't realize
bubblesort is a general term and not just a name for the method (?) of
the solution I quoted. Reading about bubblesort and all those other
sorting algorithms referenced via bubblesort has been very
illuminating!

thanks again, George

>Robert Klemme wrote:
> > georgeolivergo wrote:
> >
> >                 if a[j] > a[j+1]
> >                     a[j], a[j+1] = a[j+1], a[j] # swap
> >
> > I'm reading this to mean if the jth position in a is lexically greater
> > than the jth + 1 position, then those two positions switch places, for
> > example [z, m, p, a] becomes [ m, p, a, z], but then how does 'a' get
> > to the top of the array?
>
> Because the process is repeated n-1 times.  For better explanation I
> suggest googling for "bubble sort" and / or to buy a book on data
> structures and algorithms.  IMHO this belongs on every software
> developer's desk anyway because the topic is so fundamental.
>
>  > And is that formula of a[j], ... = ... a
> > simple equation you can use in many different ways or a more specific
> > method?
>
> No, it's the normal assignment operator - if you have multiple values
> left and right it's also called "parallel assignment" IIRC.  I do not
> know another programming language that has this feature.  Basically it
> ensures that all right hand sides are evaluated before the assignment
> takes place.  This allows to swap values like in
> 
> a,b=b,a
> 
> Kind regards
> 
> 	robert