Hi @JB_BRU, thanks for reaching out and sharing your feedback with us!
As it stands, it’s currently not possible to expand and collapse subtasks when you are sorting your tasks list. We have a request in our #productfeedback category for this feature, I suggest you to upvote here: Display subtasks on List view when project is filtered/sorted