<commit_before><%! from urllib import urlencode %>

<%def name="link_to_sort(key, title)">
  % if key == sort_key:
    % if sort_order.lower() == 'desc':
      ${_link_to_sort(key, 'asc', title + ' [v]')}
    % else:
      ${_link_to_sort(key, 'desc', title + ' [^]')}
    % endif
  % else:
    ${_link_to_sort(key, 'desc', title)}
  % endif
</%def>

<%def name="_link_to_sort(key, order, title)">
  <% 
  def merge(dic1, dic2):
    return dict(dic1.items() + dic2.items())

  def url_for_sort(key, order):
    return base_url + '?' + urlencode(merge(query_params, {'page': 1, 'sort_key': key, 'sort_order': order}))
  %>
  % if discussion_type == 'inline':
    <a class="discussion-sort-link discussion-inline-sort-link" href="javascript:void(0)" sort-url="${url_for_sort(key, order)}">${title}</a>
  % else:
    <a class="discussion-sort-link" href="${url_for_sort(key, order)}">${title}</a>
  % endif
</%def>
    
<div class="discussion-sort">
  Sort by: 
  ${link_to_sort('date', 'Date')}
  |
  ${link_to_sort('votes', 'Votes')}
  |
  ${link_to_sort('comments', 'Comments')}
</div>
<commit_msg>add class for selected sort option<commit_after><%! from urllib import urlencode %>

<%def name="link_to_sort(key, title)">
  % if key == sort_key:
    % if sort_order.lower() == 'desc':
      ${_link_to_sort(key, 'asc', title + ' [v]', 'sorted')}
    % else:
      ${_link_to_sort(key, 'desc', title + ' [^]', 'sorted')}
    % endif
  % else:
    ${_link_to_sort(key, 'desc', title)}
  % endif
</%def>

<%def name="_link_to_sort(key, order, title, cls='')">
  <% 
  def merge(dic1, dic2):
    return dict(dic1.items() + dic2.items())

  def url_for_sort(key, order):
    return base_url + '?' + urlencode(merge(query_params, {'page': 1, 'sort_key': key, 'sort_order': order}))
  %>
  % if discussion_type == 'inline':
    <a class="discussion-sort-link discussion-inline-sort-link ${cls}" href="javascript:void(0)" sort-url="${url_for_sort(key, order)}">${title}</a>
  % else:
    <a class="discussion-sort-link ${cls}" href="${url_for_sort(key, order)}">${title}</a>
  % endif
</%def>
    
<div class="discussion-sort">
  Sort by: 
  ${link_to_sort('date', 'Date')}
  |
  ${link_to_sort('votes', 'Votes')}
  |
  ${link_to_sort('comments', 'Comments')}
</div>

{'fraction_non_alphanumeric': 0.2204515272244356, 'fraction_numerical': 0.005312084993359893, 'mean_word_length': 4.317647058823529, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2958910', 'n_tokens_mistral': 905, 'n_tokens_neox': 868, 'n_words': 166}