• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SortUtils.cpp
2 
3 #include "StdAfx.h"
4 
5 #include "../../../Common/Wildcard.h"
6 
7 #include "SortUtils.h"
8 
CompareStrings(const unsigned * p1,const unsigned * p2,void * param)9 static int CompareStrings(const unsigned *p1, const unsigned *p2, void *param)
10 {
11   const UStringVector &strings = *(const UStringVector *)param;
12   return CompareFileNames(strings[*p1], strings[*p2]);
13 }
14 
SortFileNames(const UStringVector & strings,CUIntVector & indices)15 void SortFileNames(const UStringVector &strings, CUIntVector &indices)
16 {
17   const unsigned numItems = strings.Size();
18   indices.ClearAndSetSize(numItems);
19   if (numItems == 0)
20     return;
21   unsigned *vals = &indices[0];
22   for (unsigned i = 0; i < numItems; i++)
23     vals[i] = i;
24   indices.Sort(CompareStrings, (void *)&strings);
25 }
26