Check the Image :

Like for example, Job 3 is the Lowest so it comes first next is Job 5 and so on.

Here's the Code :

Public Class frmSJF Public Function NumberSorting(ByVal numbers() As Integer) _ As Integer() For j As Integer = 0 To numbers.Length - 1 For x As Integer = 0 To numbers.Length - 1 If numbers(x) > numbers(j) Then numbers(x) = numbers(x) + numbers(j) numbers(j) = numbers(x) - numbers(j) numbers(x) = numbers(x) - numbers(j) End If Next Next Return numbers End Function Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click If tbBT4.Text = "" And tbBT5.Text = "" Then Dim numbers() As Integer = {Val(tbBT1.Text), Val(tbBT2.Text), Val(tbBT3.Text)} Dim sortedNumberList() As Integer = NumberSorting(numbers) Dim ans1(3) As Integer ans1(0) = sortedNumberList(0) + 0 ans1(1) = sortedNumberList(1) + ans1(0) ans1(2) = sortedNumberList(2) + ans1(1) Label1.Text = 0 Label2.Text = ans1(0) Label3.Text = ans1(1) Label4.Text = ans1(2) lblCompAWT.Text = "0" + " + " + ans1(0).ToString + " + " + ans1(1).ToString lblCompAWTAns.Text = (0 + ans1(0) + ans1(1)).ToString + " / " + "3" lblTAWT.Text = ((0 + ans1(0) + ans1(1)) / 3).ToString + " ms" lblCompATAT.Text = ans1(0).ToString + " + " + ans1(1).ToString + " + " + ans1(2).ToString() lblCompATATAns.Text = (ans1(0) + ans1(1) + ans1(2)).ToString + " / " + "3" lblTATAT.Text = ((ans1(0) + ans1(1) + ans1(2)) / 3).ToString + " ms" ElseIf tbBT5.Text = "" Then Dim numbers() As Integer = {Val(tbBT1.Text), Val(tbBT2.Text), Val(tbBT3.Text), Val(tbBT4.Text)} Dim sortedNumberList() As Integer = NumberSorting(numbers) Dim ans2(4) As Integer ans2(0) = sortedNumberList(0) + 0 ans2(1) = sortedNumberList(1) + ans2(0) ans2(2) = sortedNumberList(2) + ans2(1) Label1.Text = 0 Label2.Text = ans2(0) Label3.Text = ans2(1) Label4.Text = ans2(2) lblCompAWT.Text = "0" + " + " + ans2(0).ToString + " + " + ans2(1).ToString + " + " + ans2(2).ToString() lblCompAWTAns.Text = (0 + ans2(0) + ans2(1) + ans2(2)).ToString + " / " + "4" lblTAWT.Text = ((0 + ans2(0) + ans2(1) + ans2(2)) / 4).ToString + " ms" lblCompATAT.Text = ans2(0).ToString + " + " + ans2(1).ToString + " + " + ans2(2).ToString() + " + " + ans2(3).ToString lblCompATATAns.Text = (ans2(0) + ans2(1) + ans2(2) + ans2(3)).ToString + " / " + "4" lblTATAT.Text = ((ans2(0) + ans2(1) + ans2(2) + ans2(3)) / 5).ToString + " ms" ElseIf tbBT4.Text = "" Then MsgBox("Do not leave this Blank") Else Dim numbers() As Integer = {Val(tbBT1.Text), Val(tbBT2.Text), Val(tbBT3.Text), _ Val(tbBT4.Text), Val(tbBT5.Text)} Dim sortedNumberList() As Integer = NumberSorting(numbers) Dim ans(5) As Double ans(0) = sortedNumberList(0) + 0 ans(1) = sortedNumberList(1) + ans(0) ans(2) = sortedNumberList(2) + ans(1) ans(3) = sortedNumberList(3) + ans(2) ans(4) = sortedNumberList(4) + ans(3) Label1.Text = 0 Label2.Text = ans(0) Label3.Text = ans(1) Label4.Text = ans(2) Label5.Text = ans(3) Label6.Text = ans(4) lblCompAWT.Text = "0" + " + " + ans(0).ToString + " + " + ans(1).ToString + " + " + ans(2).ToString() + " + " + ans(3).ToString lblCompAWTAns.Text = (0 + ans(0) + ans(1) + ans(2) + ans(3)).ToString + " / " + "5" lblTAWT.Text = ((0 + ans(0) + ans(1) + ans(2) + ans(3)) / 5).ToString + " ms" lblCompATAT.Text = ans(0).ToString + " + " + ans(1).ToString + " + " + ans(2).ToString() + " + " + ans(3).ToString + " + " + ans(4).ToString lblCompATATAns.Text = (ans(0) + ans(1) + ans(2) + ans(3) + ans(4)).ToString + " / " + "5" lblTATAT.Text = ((ans(0) + ans(1) + ans(2) + ans(3) + ans(4)) / 5).ToString + " ms" End If End Sub End Class