title: vb.net sort list of objects with custom order
body: <p>I have a list of objects and I'm trying to sort by two properties with one property being sorted by a custom order. The list has properties of ReqType and PartNumber. ReqType will be "M", "B", "S", or null and I would like to sort the list in that order. Then sort by PartNumber.</p>
  
  <pre><code>Input list:
  PartNumber    ReqType
  124           B
  125           M
  123           B
  121           S
  120           M
  115            
  
  Expected Sort:
  PartNumber    ReqType
  120           M
  125           M
  123           B
  124           B
  121           S
  115            
  </code></pre>
  
  <p>I started with the code below but that only sorts ReqType alphabetically.</p>
  
  <pre><code>Return EBom.OrderBy(Function(f) f.ReqType).ThenBy(Function(f) f.PartNumber).ToList 
  </code></pre>
  
  <p>I then found a method to create a custom sort order using the code below. Though using Ebom.Sort() doesn't seem to allow me to tack on the second sort order for PartNumber. I realize I could probably add the PartNumber sorting to the custom function but that seems like a lot of work.</p>
  
  <pre><code>EBom.Sort()
  Return EBom.ToList
  
  
  Implements IComparable(Of EBomList)
  Public Function SortReq(other As EBomList) As Integer Implements IComparable(Of EBomList).CompareTo
      If (Me.ReqType = other.ReqType) Then
          Return 0
      ElseIf (Me.ReqType = "M") Then
          Return -1
      ElseIf (Me.ReqType = "B") Then
          If (other.ReqType = "M") Then
              Return 1
          Else
              Return -1
          End If
      ElseIf (Me.ReqType = "S") Then
          If (other.ReqType = "M" Or other.ReqType = "B") Then
              Return 1
          Else
              Return -1
          End If
      Else
          Return 1
      End If
  End Function
  </code></pre>
  
  <p>Is there an easier way to sort by a custom order or at least combine the custom sort function with a .thenby(.....) to get the order I'd like?</p>