from pi_director.models.models import (
    DBSession,
    MyModel,
    )

def get_pis():
    PiList=DBSession.query(MyModel).filter(MyModel.uuid!="default").all()
    return PiList


from pi_director.models.models import (
    DBSession,
    MyModel,
    )

def get_pis():
    PiList=DBSession.query(MyModel).filter(MyModel.uuid!="default").order_by(MyModel.lastseen).all()
    return PiList


Order Pis in list by lastseen, showing non-communicating pis at the top