How can i find the current active/enabled true camera and sort list of cameras make the active camera first ?

void Start()
{
cameras = new List();
cameras.AddRange(GameObject.FindObjectsOfType());
cameras.Sort()
}

In this case the Main Camera is the active one when running the game.
So i want first to find the current active camera when running the game and then sort the List so the active camera will be first in the List.

Why do you need it in a list? How many cameras do you have?

Typically, you’ll set the main camera to have the “Main Camera” tag (this is default in a new scene). If that’s the case, you can find the main camera at any time by using the static property Camera.main.

I’m not sure I understand your need for the list though. How is it supposed to sort? From most important to least? In that case, you’ll need to add some metadata to the cameras to indicate their importance.

Either way, the way to do that would be to write a custom comparison function that matches the Comparison delegate. Then you can pass that in as an argument to the list’s Sort() function.

You’ll have to iterate through your list to find out if it is active in your heirarcy.

void SortCameras() {

for (int i = 0; i < cameras.Length; i ++) {

listItem item = cameras*;*

if (cameras*.activeInHeirarchy) {*

// Code to remove and add
}

}
As far as the moving it to the front, from what I’ve gathered from Stack is that using a linked list may be easier. It has a function, .AddFirst() that is supposed to be more efficient.
Here are a few links that may help you:
[C# Sorted List][1]
[Return Items from a List][2]
[Move Member to Front of List][3]
And here are a couple that cover the activeInHeirarchy:
[Check Active in Heirarcy][4]
[Unity Documentation: Active in Heirarchy][5]
This may not be the best or most efficient way of doing it, but it does seem like it should work to me. Hopefully this helps or gets you set in the correct direction.
_[1]: unity game engine - C# sorted LinkedList - Stack Overflow
_
[2]: Microsoft Learn: Build skills that open doors in your career
_[3]: c# - Moving a member of a List to the Front of the List - Stack Overflow
_
[4]: http://answers.unity3d.com/questions/1266169/check-if-game-object-is-active-in-hierarchy-from-a.html*_
_*[5]: https://docs.unity3d.com/ScriptReference/GameObject-activeInHierarchy.html*_