Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
723 B

  1. #include <nt.h>
  2. VOID
  3. SortUlongData (
  4. IN ULONG Count,
  5. IN ULONG Index[],
  6. IN ULONG Data[]
  7. )
  8. {
  9. LONG i;
  10. LONG j;
  11. ULONG k;
  12. //
  13. // Initialize the index array.
  14. //
  15. i = 0;
  16. do {
  17. Index[i] = i;
  18. i += 1;
  19. } while (i < (LONG)Count);
  20. //
  21. // Perform an indexed bubble sort on long data.
  22. //
  23. i = 0;
  24. do {
  25. for (j = i; j >= 0; j -= 1) {
  26. if (Data[Index[j]] >= Data[Index[j + 1]]) {
  27. break;
  28. }
  29. k = Index[j];
  30. Index[j] = Index[j + 1];
  31. Index[j + 1] = k;
  32. }
  33. i += 1;
  34. } while (i < (LONG)(Count - 1));
  35. return;
  36. }