Skip to content

Instantly share code, notes, and snippets.

@ericeijkelenboom
Created January 18, 2013 08:22
Show Gist options
  • Save ericeijkelenboom/4563136 to your computer and use it in GitHub Desktop.
Save ericeijkelenboom/4563136 to your computer and use it in GitHub Desktop.
Sorting SqlGuid
using System;
using System.Collections;
using System.Data.SqlTypes;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// Create an ArrayList of SqlGuids.
ArrayList sqlGuidList = new ArrayList();
sqlGuidList.Add(new SqlGuid("3AAAAAAA-1BBB-7CCC-DDDD-2EEEEEEEEEEE"));
sqlGuidList.Add(new SqlGuid("2AAAAAAA-2BBB-8CCC-EDDD-1EEEEEEEEEEE"));
sqlGuidList.Add(new SqlGuid("1AAAAAAA-3BBB-9CCC-FDDD-3EEEEEEEEEEE"));
sqlGuidList.Add(new SqlGuid("9AAAAAAA-4BBB-ACCC-1DDD-9EEEEEEEEEEE"));
sqlGuidList.Add(new SqlGuid("8AAAAAAA-5BBB-BCCC-2DDD-8EEEEEEEEEEE"));
sqlGuidList.Add(new SqlGuid("7AAAAAAA-6BBB-CCCC-3DDD-7EEEEEEEEEEE"));
// Sort the SqlGuids. The unsorted SqlGuids are in the same order
// as the unsorted Guid values.
sqlGuidList.Sort();
// Display the sorted SqlGuids. The sorted SqlGuid values are ordered
// differently than the Guid values.
Console.WriteLine("Sorted SqlGuids:");
foreach (SqlGuid sqlGuidValue in sqlGuidList)
{
Console.WriteLine(" {0}", sqlGuidValue);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment