def test_order_by(self):
        b = BuildingSnapshot.objects.create(source_type=3)
        # This one should be skipped.
        b.extra_data = {'ratio': None}
        b.save()

        b = BuildingSnapshot.objects.create(source_type=3)
        b.extra_data = {'ratio': 0.12, 'counter': '10'}
        b.save()

        b = BuildingSnapshot.objects.create(source_type=3)
        b.extra_data = {'ratio': 0.80, 'counter': '1001'}
        b.save()

        buildings = list(BuildingSnapshot.objects.all().json_query(
            'ratio', key_cast='float', order_by='ratio'
        ))

        self.assertEqual(buildings[0].extra_data['ratio'], None)
        self.assertEqual(buildings[1].extra_data['ratio'], 0.12)
        self.assertEqual(buildings[2].extra_data['ratio'], 0.43)
        self.assertEqual(buildings[3].extra_data['ratio'], 0.80)

        # Now test what happens when we sort in reverse order.
        buildings2 = list(BuildingSnapshot.objects.all().json_query(
            'ratio', key_cast='float', order_by='ratio', order_by_rev=True
        ))

        self.assertEqual(buildings2[0].extra_data['ratio'], 0.80)
        self.assertEqual(buildings2[1].extra_data['ratio'], 0.43)
        self.assertEqual(buildings2[2].extra_data['ratio'], 0.12)
        self.assertEqual(buildings2[3].extra_data['ratio'], None)

        # Now test alpha numeric sorting
        buildings3 = list(BuildingSnapshot.objects.all().json_query(
            'counter', order_by='counter'
        ))

        self.assertEqual(buildings3[0].extra_data['counter'], '10')
        self.assertEqual(buildings3[1].extra_data['counter'], '1001')

        # Now test reverse sort on alpha numeric sorting
        buildings4 = list(BuildingSnapshot.objects.all().json_query(
            'counter', order_by='counter', order_by_rev=True
        ))

        self.assertEqual(buildings4[0].extra_data['counter'], '1001')
        self.assertEqual(buildings4[1].extra_data['counter'], '10')
Do the actual comparison.
dataset/ETHPy150Open buildingenergy/buildingenergy-platform/seed/managers/tests/test_json_manager.py/TestJsonManager.test_order_by--crossover with--dataset/ETHPy150Open ClusterHQ/flocker/flocker/restapi/testtools.py/CloseEnoughResponse._verifyWithBody