'Check sorted on recordsets.'

@mute_logger('odoo.models')
def test_80_sorted(self):

    ps = self.env['res.partner'].search([])
    qs = (ps[:(len(ps) / 2)] + ps[(len(ps) / 2):])
    self.assertEqual(qs.sorted().ids, ps.ids)
    by_name_ids = [p.id for p in sorted(ps, key=(lambda p: p.name))]
    self.assertEqual(ps.sorted((lambda p: p.name)).ids, by_name_ids)
    self.assertEqual(ps.sorted('name').ids, by_name_ids)
    by_name_ids.reverse()
    self.assertEqual(ps.sorted('name', reverse=True).ids, by_name_ids)
