How to sort a List by a class paramater

  1. I have a Character Class constructor formed as such:

    public Character(string n, string e, int a, int b, int c, int d)

  2. In another Class, I create 8 such characters and add them to a List. How can I order that List so that ‘int b’ is the one that decides which Character will be at the top? The List would be in descending order with the largest ‘int b’ at the top. I have read of some options with using Linq or IEnumerable. Even thought about a PriorityQueue. What would be the most efficient way to implement this?

Thank you

In C# you can use LINQ.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public class ListTesdt : MonoBehaviour
{
	[System.Serializable]
	public class TestData
	{
		public int data;
	}
	
	public List<TestData> testData;
	
	void Awake()
	{
	    testData = testData.OrderBy(x => x.data).ToList();
		foreach (TestData t in testData)
			Debug.Log(t.data);
	}
}