Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

Sort question...

I have a series of int objects (see code below).  They are used as enum's, but because they are not constant (the value can change), they are int's.  I need to sort them into numerical sequence, so I can use the object name as an enum.  (Probably not the best way to do it, but it works).

What's the best way of doing this?
//  default tab order
        int cPricingResults = 0;
        int cExport = 1;
        int cUpload = 2;
        int cAccounting = 3;
        int cRepricing = 4;
        int cASIN = 5;
        int cProgramOptions = 6;
        int cCustomerInfo = 7;
        int cInvoice = 8;
        int cBookDetail = 9;
        int cSearch = 10;
        int cTabMapping = 11;
        int cImport = 12;
        int cWebPages = 13;
        int cMassChanges = 14;
        int cCatalogs = 15;
        int cCannedText = 16;
        int cUIDPswd = 17;
        int cReports = 18;
        int cStatus = 19;

Open in new window

1 Solution
Mike TomlinsonMiddle School Assistant TeacherCommented:
You could use a SortedList:

Or just a custom class with the string name and int value added to a generic List and provide your own comparer to sort them....
rmmarshAuthor Commented:
Thank you... just what I was looking for...

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now