make order consistent across Ruby vsns w/sort

Fixes #2635.  In particular, link and cookie order differ
between Ruby 1.8.7 and 2.x, causing the test suite to fail
under 1.8.7.

These `sort` operations force the orders generated by 2.x Ruby in
all cases.

This PR is a prerequisite for #2625 .