ByteArrayComparer.cs 566 B

123456789101112131415161718192021222324
  1. using System.Collections.Generic;
  2. namespace Best.HTTP.Shared.Databases.Indexing.Comparers
  3. {
  4. public sealed class ByteArrayComparer : IComparer<byte[]>
  5. {
  6. public int Compare(byte[] x, byte[] y)
  7. {
  8. int result = x.Length.CompareTo(y.Length);
  9. if (result != 0)
  10. return result;
  11. for (int i = 0; i < x.Length; ++i)
  12. {
  13. result = x[i].CompareTo(y[i]);
  14. if (result != 0)
  15. return result;
  16. }
  17. return 0;
  18. }
  19. }
  20. }