title: Sorting tweets by re-tweets/favourites
body: <p>I'm trying to implement a method whereby a user can manipulate three radio buttons, each with assigned methods, to sort the tweets either by retweets, by favourites or default(by date).</p>
  
  <p>Currently, the page lists the tweets by date as default but every time I pressed either of the two buttons, I get the error "This page does not exist."</p>
  
  <p>My .rb file is:</p>
  
  <pre><code>require 'sinatra'
  require 'twitter'
  require 'erb'
  include ERB::Util
  
  config = {
      :consumer_key =&gt;  '..' ,
      :consumer_secret =&gt; '..' ,
      :access_token =&gt; '..' ,
      :access_token_secret =&gt; '..'
  }
  
  client = Twitter::REST::Client.new(config)
  
  get '/list_of_tweets' do
     puts "Visiting history page..."
     tweets = client.user_timeline(user)
     @history = tweets.take(20)
     erb :tweets_list
  end
  </code></pre>
  
  <p>My tweets_list.erb file is:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Twitter Interface&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;h1&gt;List of Tweets&lt;/h1&gt;
  
  &lt;form method="post"&gt;
    &lt;h3&gt;Sort Tweets by&lt;/h3&gt;
    &lt;input type="radio" name="operation" value="favorite_count" checked/&gt;Favourites
    &lt;input type="radio" name="operation" value="retweet_count"/&gt;Retweets
    &lt;input type="radio" name="operation" value="default"/&gt;Default
    &lt;input type="submit" value="submit"/&gt;
  &lt;/form&gt;
  
  &lt;% unless @history.nil? %&gt;
      &lt;% if @params[:operation] == "favourite_count"%&gt;
          &lt;% @history = tweets.take(20).sort_by!{|tweet| tweet.favorite_count} %&gt;
      &lt;% else %&gt;
          &lt;% @history.reverse! %&gt;
      &lt;% end %&gt;
      &lt;% if @params[:operation] == "retweet_count" %&gt;
          &lt;% @history = tweets.take(20).sort_by!{|tweet| tweet.favorite_count} %&gt;
      &lt;% else %&gt;
          &lt;% @history.reverse! %&gt;
  &lt;% end %&gt;
      &lt;% if @params[:operation] == "default" %&gt;
      &lt;% @history = tweets.take(20) %&gt;
      &lt;% else %&gt;
          &lt;% @history.reverse! %&gt;
      &lt;% end %&gt;
  
      &lt;table border="1"&gt;
        &lt;tr&gt;
          &lt;th&gt;Time Posted&lt;/th&gt;
          &lt;th&gt;Description of Tweets&lt;/th&gt;
          &lt;th&gt;Number of Retweets&lt;/th&gt;
          &lt;th&gt;Number of Favourites&lt;/th&gt;
        &lt;/tr&gt;
  
        &lt;% @history.each do |tweet| %&gt;
            &lt;tr&gt;
              &lt;td&gt;&lt;%= tweet.created_at %&gt;&lt;/td&gt;
              &lt;td&gt;&lt;%= tweet.text %&gt;&lt;/td&gt;
              &lt;td&gt;&lt;%= tweet.retweet_count %&gt;&lt;/td&gt;
              &lt;td&gt;&lt;%= tweet.favorite_count %&gt; &lt;/td&gt;
            &lt;/tr&gt;
        &lt;% end %&gt;
      &lt;/table&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>
  </p>