highlevelcoder
highlevelcoder

Reputation: 355

K&R Task Exercise 5.17

Can someone explain what specifically needs to be done in exercise 5.17, what does it mean to sort within line, its field?

Upvotes: 1

Views: 828

Answers (2)

Aaron Digulla
Aaron Digulla

Reputation: 328770

You must find a way to split a line into fields and then be able to say "sort on field N"

Upvotes: 2

pmg
pmg

Reputation: 108988

I don't have my copy of K&R here. I think it means this

Suppose the original file has

0000087423 Volkswagen 2001-01-01
0000642396 Fiat 2002-02-02
3900063521 Renault 2003-03-03

It is already sorted by the 1st field; if you want to sort it by the 2nd field (the name) the result would be

0000642396 Fiat 2002-02-02
3900063521 Renault 2003-03-03
0000087423 Volkswagen 2001-01-01

Or you can sort by date (the 3rd field)

Upvotes: 4

Related Questions