<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -110,18 +110,25 @@ class HTMLResponse(base.BaseResponse):
 		path_names = s3response.path_components(url_escape=False)
 		path = s3response.path
 		warning_message = None
-		
+
+		sort = 'name'
+		sort_property = 'key'
+		sort_asc = True
+
 		if s3response.is_truncated:
-			sort = 'name'
-			sort_asc = True
 			if self.request.get('s', None) is not None:
 				warning_message = 'Because the result was truncated, the sort option was ignored.'
 		else:
-			# Sort files
 			sort = self.request.get('s', 'name')
-			sort_asc = self.request.get('sd', 'asc') == 'asc'
+			if sort.endswith(':d'): 
+				sort_asc = False
+				sort = sort[:-2]
+			# Change sort aliases
+			if sort == 'date': sort_property = 'last_modified'
+			elif sort == 'name': sort_property = 'key'
+			elif sort == 'size': sort_property = 'size'
 
-		files.sort(cmp=lambda x, y: shrub.utils.file_comparator(x, y, sort, sort_asc))
+		files.sort(cmp=lambda x, y: shrub.utils.file_comparator(x, y, sort_property, sort_asc))
 
 		# Default url options to pass through to links
 		url_options = dict()
@@ -163,7 +170,7 @@ class RSSResponse(base.BaseResponse):
 		path = s3response.path
 		
 		rss_items = []
-		files.sort(cmp=lambda x, y: shrub.utils.file_comparator(x, y, 'date', False))
+		files.sort(cmp=lambda x, y: shrub.utils.file_comparator(x, y, 'last_modified', False))
 
 		for file in files[:50]:
 			rss_items.append(file.to_rss_item())</diff>
      <filename>app/controllers/s3.py</filename>
    </modified>
    <modified>
      <diff>@@ -41,7 +41,7 @@ class XSPFResponse(BaseResponse):
 		if self.request.get('format', '') == 'xspfm':
 			extensions = ['mp3']
 
-		files.sort(cmp=lambda x, y: shrub.utils.file_comparator(x, y, 'name', True))
+		files.sort(cmp=lambda x, y: shrub.utils.file_comparator(x, y, 'key', True))
 
 		tracks = [file.xspf_track for file in files if not extensions or file.extension in extensions]
 		#logging.info(&quot;Tracks: %s&quot; % ([str(track) for track in tracks]))</diff>
      <filename>app/controllers/tape.py</filename>
    </modified>
    <modified>
      <diff>@@ -8,4 +8,4 @@ def to_json(context, value):
 	return simplejson.dumps(value)
 
 def shrub_version(context):
-	return &quot;1.2.14&quot;
\ No newline at end of file
+	return &quot;1.2.15&quot;
\ No newline at end of file</diff>
      <filename>app/helpers/base.py</filename>
    </modified>
    <modified>
      <diff>@@ -3,24 +3,25 @@ def header_link(context, label, name, sort, sort_asc, path):
 	icon = ''
 	class_ = ''
 	sort_attr = name
-	sort_dir = 'asc'
-	
+	# Default to descending for first sort option for date
+	sort_dir = ':d' if name == 'date' else ''
+
 	if sort == name:
 		if not sort_asc:
 			class_ = 'asc'
-			sort_dir = 'asc'
+			sort_dir = ''
 			icon = 'bullet_arrow_down.png'
 		else:
 			class_ = 'desc'
-			sort_dir = 'desc'
+			sort_dir = ':d'
 			icon = 'bullet_arrow_up.png'
 
 	context.write('''&lt;th class=&quot;sorted %s %s&quot; onclick=&quot;document.location.href='/%s/?s=%s'&quot;&gt;''' % (class_, name, path, sort_attr))
-	context.write('''&lt;a href=&quot;/%s/?s=%s&amp;sd=%s&quot;&gt;%s&lt;/a&gt;''' % (path, sort_attr, sort_dir, label))
+	context.write('''&lt;a href=&quot;/%s/?s=%s%s&quot;&gt;%s&lt;/a&gt;''' % (path, sort_attr, sort_dir, label))
 
 	if icon: context.write('&lt;img src=&quot;/shrub/images/%s&quot;/&gt;&lt;/th&gt;' % icon)
 	return ''
-	
+
 def if_even(context, n, if_label, else_label):
 	if n % 2 == 0:
 		return if_label</diff>
      <filename>app/helpers/list.py</filename>
    </modified>
    <modified>
      <diff>@@ -28,9 +28,6 @@ def params_to_url(params, urlescape=False):
 	return '&amp;'.join(pairs)
 
 def file_comparator(x, y, sort, sort_asc):
-	# Change sort aliases
-	if sort == &quot;date&quot;: sort = &quot;last_modified&quot;
-	if sort == &quot;name&quot;: sort = &quot;key&quot;
 
 	a = b = None
 
@@ -42,8 +39,8 @@ def file_comparator(x, y, sort, sort_asc):
 	elif a is not None and b is None: return -1
 	elif a is None and b is None: return 0
 
-	if isinstance(a, str): a = a.lower()
-	if isinstance(b, str): b = b.lower()
+	if isinstance(a, str) or isinstance(a, unicode): a = a.lower()
+	if isinstance(b, str) or isinstance(b, unicode): b = b.lower()
 
 	if sort_asc: return cmp(a, b)
 	else: return cmp(b, a)</diff>
      <filename>shrub/utils.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a4009dee6005751b68a3776be406dc2b5c2eac1c</id>
    </parent>
  </parents>
  <author>
    <name>Gabriel Handford</name>
    <email>gabrielh@gmail.com</email>
  </author>
  <url>http://github.com/gabriel/shrub/commit/cf47d10b23cff31a0f271c1e080220d71fd8966f</url>
  <id>cf47d10b23cff31a0f271c1e080220d71fd8966f</id>
  <committed-date>2009-07-23T01:29:10-07:00</committed-date>
  <authored-date>2009-07-23T01:29:10-07:00</authored-date>
  <message>Changing sort params</message>
  <tree>7a184cc2e254b31a9184480eb67613086ee495d7</tree>
  <committer>
    <name>Gabriel Handford</name>
    <email>gabrielh@gmail.com</email>
  </committer>
</commit>
