title: Scheduling algorithm FCFS in python
body: <p>I need to implement <em>First Come First Served</em> scheduling algorithm in Python so I have to sort arrival time in ascending order. I get the error <code>list index out of range</code>.  What should be the condition for sorting?  I think my condition is correct, but it is not working.</p>
  
  <pre><code>arrival_time=[]
  
  burst_time=[]
  
  ch=int(input("Enter number of processes:"))
  
  i=0
  
  while i&lt;ch:
  
      a=int(input("Enter arrival time:"))
      b=int(input("Enter burst time:"))
      arrival_time.insert(i,a)
      burst_time.insert(i,b)
      i=i+1
  
  print("Process Arrival Time  Burst Time ")
  print(arrival_time,burst_time)
  
  count=0
  
  for j in range(ch-1):
       for l in range(l+1+count,ch):
          if arrival_time[j]&gt;arrival_time[l+1+count]:
              temp=arrival_time[j]
              arrival_time[j]=arrival_time[l+1+count]
              arrival_time[l+1+count]=temp
       count=count+1
  
  
  print(arrival_time)  
  k=0
  sum=0
  print("Gantt Chart")
  
  while k&lt;ch:
      if k==0:
          sum=sum+burst_time[k]      
          print(arrival_time[k],"------",sum)
  
      elif k&gt;0:
  
          sum1=sum+burst_time[k]       
          print("-------",sum1)
  
      k=k+1
  </code></pre>