CSharp · Console
using System;
using System.Collections.Generic;
using System.Linq;
public class Student {
public string name {get; set;}
public string standard { get; set;}
public string section {get; set;}
public int rollNumber {get; set;}
}
public class Program
{
public static void Main()
{
List<Student> students = new List<Student>(){
new Student {name ="Bob", standard = "Third", section ="A", rollNumber=10},
new Student {name ="Smith", standard = "Second", section ="B", rollNumber=5},
new Student {name ="Tylor", standard = "First", section ="A", rollNumber=1},
new Student {name ="Jack", standard = "Third", section ="A", rollNumber=8},
new Student {name ="Penny", standard = "Second", section ="B", rollNumber=4},
new Student {name ="Diana", standard = "First", section ="A", rollNumber=1},
new Student {name ="Selena", standard = "First", section ="B", rollNumber=3},
new Student {name ="Elon", standard = "Second", section ="A", rollNumber=1},
new Student {name ="Harry", standard = "Second", section ="B", rollNumber=1},
};
List<string> sortedStandard = new List<string>() {"Second", "First", "Third"};
List<string> sortedSection = new List<string>() {"B", "A"};
List<Student> sortedStudents = students.
OrderBy(x => sortedStandard.IndexOf(x.standard)).
ThenBy(x => sortedSection.IndexOf(x.section)).
ThenBy(x => x.rollNumber).ToList();
Console.WriteLine("............Sorted Students---------------");
Console.WriteLine();
sortedStudents.Dump();
Console.WriteLine(sortedStandard.IndexOf("Second"));
}
}