I have a file, x.txt, of lines where a typical line is:

7|22|Come let us praise the Lord

Currently it is ordered on the first column and I want to order it on =
the third column, where columns are separated by '|'. At the terminal I =
type the following line and I get what I want in y.txt.

sort -t\| -k 3,3d x.txt -o y.txt

In ruby I tried both the following and for neither is y.txt created.

system("sort -t\| -k 3,3d x.txt -o y.txt")
res =3D `sort -t\| -k 3,3d x.txt -o y.txt`

In the second of these, res =3D "" after running it and there is the =
following message at the terminal:

sh: -k: command not found
sort: option requires an argument -- t
Try `sort --help' for more information.

I tried several things mentioned in 'sort --help' but got no nearer.

If anyone can help at all, I'd be very grateful. I'm on an iMac running =
OS X v. 10.6.8 and Ruby 1.9.3.

Barrie.=