Fix contract profiler path shortening.

Was not preserving list order while shortening.