title: Dashing - lists widget
body: <p>I am using the "lists" widget in dashing to display a string and a value (in this case the name of the user and number of jobs running on the batch system).</p>
  
  <p>I would like this displayed sorted by value (number of jobs) in descending order.  It currently reads these in from a csv file that contains the string (username) and value (number of jobs), sorted in descending order.</p>
  
  <pre><code>CSV.foreach('/path/to/file.csv') do |row|
      user = row[0]
      numberOfJobs = row[1]
      SGE_list[user] =  { label: user, value: numberOfJobs }
  end
  </code></pre>
  
  <p>As soon as dashing starts, and reads the file for the first time, this is correct.  However when it re-reads the file (which is continuously updated) then it keeps the original order, (regardless of the order in the csv file).</p>
  
  <p>Any suggestions?</p>
  
  <p>Full jobs file:</p>
  
  <pre><code>require 'csv'
  
  JOB_list = Hash.new({ value: 0 })
  
  SCHEDULER.every '5m' do
  
    groups = ["user1", "user2", "user3", "user4", "user5", "user6", "user7", "user8"]
  
    # Read in to get order                                                        
    CSV.foreach('/opt/dashing/sweet_dashboard_project/jobs/qusage.csv') do |row|
      user = row[0]
      numberOfJobs = row[1]
      JOB_list[user] =  { label: user, value: numberOfJobs }
    end
  
    # blank all values                                                            
    for g in groups
      JOB_list[g] =  { label: g, value: 0 }
    end
  
    CSV.foreach('/opt/dashing/sweet_dashboard_project/jobs/qusage.csv') do |row|
      user = row[0]
      numberOfJobs = row[1]
      JOB_list[user] =  { label: user, value: numberOfJobs }
    end
  
    send_event('batch_jobs', { items: JOB_list.values })
  
  end
  </code></pre>
  
  <p>The csv file can vary. it could be:
  user7, 1000
  user2, 987
  user8, 800
  user6, 400
  user5, 200
  user4, 122
  user1, 89
  user3, 2</p>
  
  <p>or, if the user is not running a job, they are not listed so:</p>
  
  <p>user6, 340
  user5, 123
  user4, 101</p>
  
  <p>it is always sorted by the 2nd column.</p>