/* Sort memory resource entries based upon PhysicalStart, from low to high. */
VOID SortMemoryResourceDescriptor(IN OUT MEMORY_RESOURCE_DESCRIPTOR *MemoryResource)
/* Sort memory resource entries based upon PhysicalStart, from low to high. */
VOID SortMemoryResourceDescriptor(IN OUT MEMORY_RESOURCE_DESCRIPTOR *MemoryResource)
{
  MEMORY_RESOURCE_DESCRIPTOR  *MemoryResourceEntry;
  MEMORY_RESOURCE_DESCRIPTOR  *NextMemoryResourceEntry;
  MEMORY_RESOURCE_DESCRIPTOR  TempMemoryResource;
  MemoryResourceEntry     = MemoryResource;
  NextMemoryResourceEntry = MemoryResource + 1;
  while (MemoryResourceEntry->ResourceLength != 0) {
    while (NextMemoryResourceEntry->ResourceLength != 0) {
      if (MemoryResourceEntry->PhysicalStart > NextMemoryResourceEntry->PhysicalStart) {
        CopyMem (&TempMemoryResource, MemoryResourceEntry, sizeof (MEMORY_RESOURCE_DESCRIPTOR));
        CopyMem (MemoryResourceEntry, NextMemoryResourceEntry, sizeof (MEMORY_RESOURCE_DESCRIPTOR));
        CopyMem (NextMemoryResourceEntry, &TempMemoryResource, sizeof (MEMORY_RESOURCE_DESCRIPTOR));
      }
      NextMemoryResourceEntry = NextMemoryResourceEntry + 1;
    }
    MemoryResourceEntry     = MemoryResourceEntry + 1;
    NextMemoryResourceEntry = MemoryResourceEntry + 1;
  }
}