Sort the Yanfly Party System list

Hello! Yanfly Party System for RPG Maker VX Ace is very cool, but not very convenient when you've got more than 200 actors...
Is it possible to arrange it to sort the character list with name at alphabetical order ?

I tried to add in my party the new member with alphabetical order, but when I did some modification of my active team with Formation, the list became in disorder because the script for formation doesn't put the list first order back after each manipulation...

Could you help me, please?
So you are basically asking to sort actors that are not in the active party in alphabetical order each time, did I hit the mark?

I've moved this thread to RGSSx Script Support. Thank you.

So you are basically asking to sort actors that are not in the active party in alphabetical order each time, did I hit the mark?

Yes! That's it! 👍
Could you please post a link to the script? This does not sound as a difficult task.
Sure !
The Party Manager script from Yanfly is here :
Yanfly Party System
Just copy/paste this in your scripts BELOW Yanfly Party System. You can either sort actors alphabetically or based on their database ID. As written in the instruction I strongly recommend doing it by database ID - especially if you have a large number of actors - however it works for alphabetical order as well.

Spoiler: Code inside
Code:
$imported = {} if $imported.nil?
$imported["Heirukichi_SortActorsFromation"] = true

module HSF
   
    #=======================================================================
    # Set this value to true if you want to sort actors alphabetically
    # Set it to false if you want to sort them by ID.
    # Default is true.
    #-----------------------------------------------------------------------
    # * NOTE
    #-----------------------------------------------------------------------
    # Sorting them alphabetically is more time-consuming than sorting
    # them by ID so I strongly recommend sorting them in your database
    # and then sorting them by ID.
    #=======================================================================
   
    SORT_ALPHABETICALLY = true
   
    #=======================================================================
    # Set this value to true if you want to sort actors more efficiently.
    # It only works for alphabetical sorting. Default is true.
    #=======================================================================
   
    EFFICIENT_SORTING = true
   
    #=======================================================================
    # Do not modify after this point!
    #=======================================================================
   
    def self.compare(a, b)
        return if (a.nil? || b.nil?)
        return if ($data_actors[a].nil? || $data_actors[b].nil?)
        EFFICIENT_SORTING ? pcompare(a, b) : $data_actors[a].name <=> $data_actors[b].name
    end
   
    def self.initialize_actors_priority
        return unless @actors_priority.nil?
        @actors_priority = Array.new($data_actors.length+1) {|i| i}
        $data_actors.each.with_index do |a, i|
            next if (i==0)
            p = 0
            $data_actors.each.with_index do |b, j|
                next if (j==0)
                next if (a==b)
                p += 1 if a.name > b.name
            end
            @actors_priority[i] = p
        end
    end
   
    def self.priority
        @actors_priority
    end
   
    def self.pcompare(a, b)
        return if (a.nil? || b.nil?)
        return if ($data_actors[a].nil? || $data_actors[b].nil?)
        initialize_actors_priority
        priority[a] <=> priority[b]
    end
   
end

if $imported["YEA-PartySystem"]

#===========================================================================
# * Game Party class
#===========================================================================

class Game_Party
       
    alias hrk_rearrange_actors_old    rearrange_actors
    def rearrange_actors
        hrk_rearrange_actors_old
        sz = @battle_members_array.length
        sorted = @actors.slice!(sz, @actors.length - sz)
        if HSF::SORT_ALPHABETICALLY
            @actors += sorted.sort {|a, b| HSF.compare(a, b)}
        else
            @actors += sorted.sort
        end
    end
   
end

#===========================================================================
# * Scene Party class
#===========================================================================

class Scene_Party
   
    alias hrk_start_yep_old start
    def start
        hrk_start_yep_old
        window_refresh
    end
   
end

#===========================================================================
# * Scene Manu class
#===========================================================================

class Scene_Menu
   
    alias hrk_start_old    start
    def start
        hrk_start_old
        HSF.initialize_actors_priority
    end
   
end

end

This should fix your problem. However I am going to write a more efficient algorithm so that sorting actors alphabetically will be more efficient.

EDIT: I changed the code so that sorting alphabetically is more efficient.
It works perfectly! Whether alphabetically or ID based!
Thank you so much, Heirukichi! 😍
I couldn't have done it without your help!

Original thread: https://forums.rpgmakerweb.com/threads/sort-the-yanfly-party-system-list.106975/