Sorting numbers per surface panel model

Hi Dears, Any help how to fix my definition to have option to sort the surface numbering?

sort by the panel centroids instead of the surface order, that usually fixes the scrambled numbering. for the top view in your screenshot, sorting by y first then x should give you rows running 1, 2, 3 across like you marked

Please share your file so someone can show you how this could be done.