pub fn sort_windows(&mut self) {
        let mut sorter = WindowSorter::new(self.windows.iter().collect());

        // Windows explicitly marked as on top
        sorter.sort(|w| w.states.contains(&WindowState::Above) && w.floating());

        // Transient windows should be above a fullscreen/maximized parent
        sorter.sort(|w| {
            w.transient.is_some_and(|trans| {
                self.windows
                    .iter()
                    .any(|w| w.handle == trans && (w.is_fullscreen() || w.is_maximized()))
            })
        });

        // Fullscreen windows
        sorter.sort(Window::is_fullscreen);

        // Dialogs and modals.
        sorter.sort(|w| {
            w.r#type == WindowType::Dialog
                || w.r#type == WindowType::Splash
                || w.r#type == WindowType::Utility
                || w.r#type == WindowType::Menu
        });

        // Floating windows.
        sorter.sort(|w| w.r#type == WindowType::Normal && w.floating());

        // Maximized windows.
        sorter.sort(|w| w.r#type == WindowType::Normal && w.is_maximized());

        // Tiled windows.
        sorter.sort(|w| w.r#type == WindowType::Normal);

        // Last docks.
        sorter.sort(|w| w.r#type == WindowType::Dock);

        // Finish and put all unsorted at the end.
        let windows = sorter.finish();
        let handles = windows.iter().map(|w| w.handle).collect();

        // SetWindowOrder is passed to the display server
        let act = DisplayAction::SetWindowOrder(handles);
        self.actions.push_back(act);
    }
Sorts the windows and puts them in order of importance.
leftwm-core/src/state.rs