'Validate an image list that has been sorted by size
Perform list action with given params and validates the results are
sorted by image size in either ascending or descending order.'

def _list_sorted_by_image_size_and_assert(self, params, desc=False):

    images_list = self.client.list_images(params=params)['images']
    msg = 'No    images    were    found    that    met    the    filter    criteria.'
    self.assertNotEmpty(images_list, msg)
    sorted_list = [image['size'] for image in images_list]
    msg = 'The    list    of    images    was    not    sorted    correctly.'
    self.assertEqual(sorted(sorted_list, reverse=desc), sorted_list, msg)
