Python sorted object

I have query that is sorted via python however I would like to exclude the brands with the distance greater than 100km this is what I wrote, however it always gets distance that is beyond 100km

 return sorted(
    root.brands.filter(status=True, region_id=area),
            key=lambda qs: (qs.distance(**kwargs) <= 100, qs.distance(**kwargs) < 100 if 
   qs.distance(**kwargs) > 0 else [])
 )

is there any way to do this? thanks

Back to Top