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
Order Pis in list by lastseen, showing non-communicating pis at the top

  from pi_director.models.models import (
      DBSession,
      MyModel,
      )
  
  def get_pis():
-     PiList=DBSession.query(MyModel).filter(MyModel.uuid!="default").all()
+     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
## Code Before:
from pi_director.models.models import (
    DBSession,
    MyModel,
    )

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


## Instruction:
Order Pis in list by lastseen, showing non-communicating pis at the top
## Code After:
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

