Click here to Skip to main content
15,891,316 members
Articles / Programming Languages / C#

Custom Sort a List of Objects by Any Order

Rate me:
Please Sign up or sign in to vote.
4.93/5 (16 votes)
14 Mar 2012CPOL4 min read 78.8K   91   25  
An IList Extension Method that sorts the list in any order or in a combination of orders.

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomSorter", "CustomComparer\CustomSorter.csproj", "{A4A2C3F1-C991-4276-B852-D87DE7AFF222}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomSorterSpecifications", "ComparerSpecifications\CustomSorterSpecifications.csproj", "{D5C73998-3026-469C-ADEB-8CE281443168}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{A4A2C3F1-C991-4276-B852-D87DE7AFF222}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{A4A2C3F1-C991-4276-B852-D87DE7AFF222}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{A4A2C3F1-C991-4276-B852-D87DE7AFF222}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{A4A2C3F1-C991-4276-B852-D87DE7AFF222}.Release|Any CPU.Build.0 = Release|Any CPU
		{D5C73998-3026-469C-ADEB-8CE281443168}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{D5C73998-3026-469C-ADEB-8CE281443168}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{D5C73998-3026-469C-ADEB-8CE281443168}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{D5C73998-3026-469C-ADEB-8CE281443168}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader XYZ Studios Ltd
China China
I am an independent IT contractor who is passionate about life and Microsoft technology stack. I have been programming since 2001. Besides coding, I also enjoy diving, swimming, rock climbing and travelling. I swim 2 miles a day to keep my morale and energy level consistently high.

Comments and Discussions