```On Sep 22, 2010, at 21:30 , Paul wrote:

>> Silly me.  You can also pass a block to the Array#sort method.  That
>> block will receive 2 arguments which you may then compare as you =
wish,
>> returning -1 if the first argument sorts before the last, 0 if they =
are
>> equal, and 1 if the last argument sorts before the first.
>=20

> Do you have an example of what this might look like?  To clarify what
> I want to see, here is how the data should be sorted:
>=20
> [["ABC-1", 1271768400, 2],
> ["DEF-1", 1271772000, 1],
> ["ABC-2", 1271773800, 1],
> ["AAA-1", 1271862000, 2],
> ["ABC-3", 1271863200, 2],
> ["ABC-4", 1271869200, 2]]

I'm not sure anybody really explained this well.=20

arr.sort! do |a,b|
#stuff to sort the array goes here
end

What that does is it puts one array element in a, and one in b. So, for =
example, you might have
a =3D ["DEF-1", 1271772000, 1]
and
b =3D ["ABC-2", 1271773800, 1]

So what you have to do in the "#stuff to sort the array goes here" is =
whatever code you need to have to figure out which one of those two =
comes first. It sounds like you need something like a[0].split("-")[0] =
to extract out the "DEF" or the "ABC" first, in order to sort by the =
label? Because a[0] is, of course, "DEF-1".=20

sortorder =3D (a[0].split("-")[0] <=3D> b[0].split("-")[0])
if sortorder =3D=3D 0 then
a[1]<=3D>b[1]
else
sortorder
end

(You might need to look up what the <=3D> operator does...also, that's =
not how I would normally write that code. I was verbose for clarity's =
sake. ) If I understand your explanation correctly, then that code will =