Learning to Rank with Nonsmooth Cost Functions