Sort list in microflow by associated attribute

Hi all   My domain model looks like this: Certificate object is associated with one doctor. Doctor is asociated with one nurse. A nurse has many doctors.   I want to retrieve a list of all the certificates linked to the doctors linked to the logged in nurse. This is not a problem: I do this using a loop iterating over all the doctors linked to the nurse and there I add the certificates linked to the doctor Im iterating over. So a nice list of certificates.   However, i now want to sort the list by doctor name but the doctor name is not in the list (because it is a association with the certificate).   How can i work around this?   Thanks!  
1 answers

Hi Jeremie,

If this is persistent data, you could retrieve and sort the data directly by using a retrieve from database. If not (or the data has not been committed yet), you could first sort the list of doctors by name, then iterate over this sorted list, retrieve all the certificates per doctor, and add this to the result list.

​​​​​​​Hope this helps!