Я нашел решение для того же вопроса на этом сайте
from tkinter import Tk
from tkinter.ttk import Label
root = Tk()
Label(root, text="Hello world").pack()
# Apparently a common hack to get the window size. Temporarily hide the
# window to avoid update_idletasks() drawing the window in the wrong
# position.
root.withdraw()
root.update_idletasks() # Update "requested size" from geometry manager
x = (root.winfo_screenwidth() - root.winfo_reqwidth()) / 2
y = (root.winfo_screenheight() - root.winfo_reqheight()) / 2
root.geometry("+%d+%d" % (x, y))
# This seems to draw the window frame immediately, so only call deiconify()
# after setting correct window position
root.deiconify()
root.mainloop()
Конечно, я изменил его соответственно моим целям, он работает.
Есть некоторые проблемы, которые вы должны рассмотреть:
Поэтому, я думаю, единственный эффективный способ - это перевести его в граф (многодетное дерево) с указателями вместо индексов.
struct Object2
{
void* data;
Object2* FirstChild; // Will point to first child (if there is), or null.
Object2* NextSibling;// Will point to next sibling (if there is), or null.
};
На самом деле, вы можете использовать любую библиотеку XML для сортировки: