Custom Sorting Numbers in a Non-Linear Orders

I had a problem where a company wanted an array of pictures from a database custom sorted. The pictures already had ID’s assigned to them from a database index.

The items selected would be of varying lengths each time, and not all images would be selected or used.

Computers are great at sorting numbers ascending and descending, but there is really no simple way to order numbers in a nonlinear order.

So taking those indices and the order they requested, I finally came up with a fairly simple way to reorder the requested items without having to hardcode the silly order in.
Dim order() As Integer = {20, 18, 15, 4, 6, 13, 3, 19, 2, 14, 0, 5, 16, 1, 10, 7, 11, 8, 12, 9, 17}
Dim items() As Integer = {9, 12, 14, 14, 5, 8, 3, 10, 18, 20}
Dim dtsort As New DataTable
TextBox1.Clear()
dtsort.Columns.Add("val", GetType(Integer))
dtsort.Columns.Add("sort", GetType(Integer))

For Each i As Integer In items
dtsort.Rows.Add(i, Array.IndexOf(order, i))
Next

Dim dv As New DataView(dtsort)
dv.Sort = "sort ASC"

For Each row As DataRowView In dv
TextBox1.AppendText(row.Item("val") & vbCrLf)
Next