Make sure you’re searching for the general topic, not something exclusive to your specific case. Maybe no one has asked specifically about sorting framing members by width and depth, but plenty of people have asked about sorting by multiple values.
You need to sort and group in order to retain separate “levels” , otherwise you’re just resorting the same list every time.