<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>19509</bug_id>
          
          <creation_ts>2008-06-11 19:49:51 -0700</creation_ts>
          <short_desc>Database Tables in the Inspector should be sortable</short_desc>
          <delta_ts>2010-06-18 20:35:14 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Inspector (Deprecated)</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Keishi Hattori">keishi</reporter>
          <assigned_to name="Jessie Berlin">jberlin</assigned_to>
          <cc>jberlin</cc>
    
    <cc>timothy</cc>
    
    <cc>tom.devart</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>83081</commentid>
    <comment_count>0</comment_count>
    <who name="Keishi Hattori">keishi</who>
    <bug_when>2008-06-11 19:49:51 -0700</bug_when>
    <thetext>Database tables in the Inspector should be sortable by clicking on the headers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>140701</commentid>
    <comment_count>1</comment_count>
    <who name="Tom">tom.devart</who>
    <bug_when>2009-08-17 05:13:03 -0700</bug_when>
    <thetext>It would also be helpful if you could adjust the widths of individual columns, currently you have to adjust the width of the entire window. 

Any news on if this is being looked at?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>229231</commentid>
    <comment_count>2</comment_count>
      <attachid>56774</attachid>
    <who name="Jessie Berlin">jberlin</who>
    <bug_when>2010-05-21 21:08:00 -0700</bug_when>
    <thetext>Created attachment 56774
Adds the ability to sort a Database Table in the Web Inspector.

It is already possible to resize the columns. This patch just adds the ability to sort the table based on the contents of the selected column. Works on both the tables in the Table View and the tables that show up in the Query View.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>237684</commentid>
    <comment_count>3</comment_count>
      <attachid>56774</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2010-06-13 20:53:15 -0700</bug_when>
    <thetext>Comment on attachment 56774
Adds the ability to sort a Database Table in the Web Inspector.

&gt; +            var comparison;
&gt; +            if (isNaN(item1) || isNaN(item2))
&gt; +                comparison = item1 &lt; item2 ? -1 : (item1 &gt; item2 ? 1 : 0);
&gt; +            else {
&gt; +                // Don&apos;t sort numbers alphanumerically.
&gt; +                var number1 = parseFloat(item1);
&gt; +                var number2 = parseFloat(item2);
&gt; +                comparison = number1 &lt; number2 ? -1 : (number1 &gt; number2 ? 1 : 0);
&gt; +            }

I think the comments here are a little strange and the code a bit oblique. I presume the idea here is that if the values are both numeric, we want to compare them as numbers. But I don&apos;t see how isNaN accomplishes this. What does that function do exactly? Does it look only at the numeric prefix of a number or will it return false for something like &quot;1a&quot;. Also, comparing some pairs with one sort function and other pairs with a different one is going to create trouble for the sort algorithm. Fortunately we fixed this a while back so it couldn&apos;t cause a crash in JavaScriptCore by using a tree sort rather than something like qsort that depends on consistent results from sort function.

If you wanted the code to behavior like this I think you&apos;d need to explain why isNaN works to check if things are numeric. Even though NaN is &quot;not a number&quot;, I think the usage here is unclear.

But I think there are some possibly better options:

   1) Distinguish numeric columns and non-numeric columns and chose the sort function based on the column type.

   2) Write a comparison function that works like kCFCompareNumerically, although I&apos;m not sure that will give results that are good for columns of floating point numbers.

   3) Scan the column and sort numerically only if every item in the column s a number.

Maybe you can think of something else that will work even better. Also, I would say &quot;Sort numbers based on comparing their values rather than a lexicographical comparison&quot;. I think the term &quot;alphanumerically&quot; doesn&apos;t describe lexicographical comparison.

r=me as is, but I think the comparison function can be improved</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>240253</commentid>
    <comment_count>4</comment_count>
    <who name="Jessie Berlin">jberlin</who>
    <bug_when>2010-06-18 20:35:02 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; (From update of attachment 56774 [details])
&gt; &gt; +            var comparison;
&gt; &gt; +            if (isNaN(item1) || isNaN(item2))
&gt; &gt; +                comparison = item1 &lt; item2 ? -1 : (item1 &gt; item2 ? 1 : 0);
&gt; &gt; +            else {
&gt; &gt; +                // Don&apos;t sort numbers alphanumerically.
&gt; &gt; +                var number1 = parseFloat(item1);
&gt; &gt; +                var number2 = parseFloat(item2);
&gt; &gt; +                comparison = number1 &lt; number2 ? -1 : (number1 &gt; number2 ? 1 : 0);
&gt; &gt; +            }
&gt; 
&gt; I think the comments here are a little strange and the code a bit oblique. I presume the idea here is that if the values are both numeric, we want to compare them as numbers. But I don&apos;t see how isNaN accomplishes this. What does that function do exactly? Does it look only at the numeric prefix of a number or will it return false for something like &quot;1a&quot;. Also, comparing some pairs with one sort function and other pairs with a different one is going to create trouble for the sort algorithm. Fortunately we fixed this a while back so it couldn&apos;t cause a crash in JavaScriptCore by using a tree sort rather than something like qsort that depends on consistent results from sort function.
&gt; 
&gt; If you wanted the code to behavior like this I think you&apos;d need to explain why isNaN works to check if things are numeric. Even though NaN is &quot;not a number&quot;, I think the usage here is unclear.

I am now using isNaN with the result from Number(item).

&gt; 
&gt; But I think there are some possibly better options:
&gt; 
&gt;    1) Distinguish numeric columns and non-numeric columns and chose the sort function based on the column type.
&gt; 
&gt;    2) Write a comparison function that works like kCFCompareNumerically, although I&apos;m not sure that will give results that are good for columns of floating point numbers.
&gt; 
&gt;    3) Scan the column and sort numerically only if every item in the column s a number.

I went with this option.

&gt; 
&gt; Maybe you can think of something else that will work even better. Also, I would say &quot;Sort numbers based on comparing their values rather than a lexicographical comparison&quot;. 

Fixed the comment.

&gt; I think the term &quot;alphanumerically&quot; doesn&apos;t describe lexicographical comparison.
&gt; 
&gt; r=me as is, but I think the comparison function can be improved

Thanks for the review! Committed in r61463: http://trac.webkit.org/changeset/61463</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>56774</attachid>
            <date>2010-05-21 21:08:00 -0700</date>
            <delta_ts>2010-06-18 20:35:14 -0700</delta_ts>
            <desc>Adds the ability to sort a Database Table in the Web Inspector.</desc>
            <filename>makeDataBaseTablesSortable.patch</filename>
            <type>text/plain</type>
            <size>2993</size>
            <attacher name="Jessie Berlin">jberlin</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1dlYkNvcmUvQ2hhbmdlTG9nIGIvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXgg
NTg2MTQyNi4uZmNkNzgyMSAxMDA2NDQKLS0tIGEvV2ViQ29yZS9DaGFuZ2VMb2cKKysrIGIvV2Vi
Q29yZS9DaGFuZ2VMb2cKQEAgLTEsMyArMSwxOCBAQAorMjAxMC0wNS0yMSAgSmVzc2llIEJlcmxp
biAgPGpiZXJsaW5Ad2Via2l0Lm9yZz4KKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9P
UFMhKS4KKworICAgICAgICBCdWcgMTk1MDkgLSBEYXRhYmFzZSBUYWJsZXMgaW4gdGhlIEluc3Bl
Y3RvciBzaG91bGQgYmUgc29ydGFibGUKKyAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcv
c2hvd19idWcuY2dpP2lkPTE5NTA5CisKKyAgICAgICAgKiBpbnNwZWN0b3IvZnJvbnQtZW5kL1N0
b3JhZ2VQYW5lbC5qczoKKyAgICAgICAgKFdlYkluc3BlY3Rvci5TdG9yYWdlUGFuZWwucHJvdG90
eXBlLmRhdGFHcmlkRm9yUmVzdWx0KToKKyAgICAgICAgTWFrZSBlYWNo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vZGUxLmRhdGFbc29ydENvbHVtbklkZW50aWZpZXJdOworICAgICAgICAgICAg
dmFyIGl0ZW0yID0gZGF0YUdyaWROb2RlMi5kYXRhW3NvcnRDb2x1bW5JZGVudGlmaWVyXTsKKwor
ICAgICAgICAgICAgdmFyIGNvbXBhcmlzb247CisgICAgICAgICAgICBpZiAoaXNOYU4oaXRlbTEp
IHx8IGlzTmFOKGl0ZW0yKSkKKyAgICAgICAgICAgICAgICBjb21wYXJpc29uID0gaXRlbTEgPCBp
dGVtMiA/IC0xIDogKGl0ZW0xID4gaXRlbTIgPyAxIDogMCk7CisgICAgICAgICAgICBlbHNlIHsK
KyAgICAgICAgICAgICAgICAvLyBEb24ndCBzb3J0IG51bWJlcnMgYWxwaGFudW1lcmljYWxseS4K
KyAgICAgICAgICAgICAgICB2YXIgbnVtYmVyMSA9IHBhcnNlRmxvYXQoaXRlbTEpOworICAgICAg
ICAgICAgICAgIHZhciBudW1iZXIyID0gcGFyc2VGbG9hdChpdGVtMik7CisgICAgICAgICAgICAg
ICAgY29tcGFyaXNvbiA9IG51bWJlcjEgPCBudW1iZXIyID8gLTEgOiAobnVtYmVyMSA+IG51bWJl
cjIgPyAxIDogMCk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICByZXR1cm4gc29ydERpcmVj
dGlvbiAqIGNvbXBhcmlzb247CisgICAgICAgIH0KKworICAgICAgICBub2Rlcy5zb3J0KGNvbXBh
cmF0b3IpOworICAgICAgICBkYXRhR3JpZC5yZW1vdmVDaGlsZHJlbigpOworICAgICAgICBmb3Ig
KHZhciBpID0gMDsgaSA8IG5vZGVzLmxlbmd0aDsgaSsrKQorICAgICAgICAgICAgZGF0YUdyaWQu
YXBwZW5kQ2hpbGQobm9kZXNbaV0pOworICAgIH0sCisKICAgICB1cGRhdGVET01TdG9yYWdlOiBm
dW5jdGlvbihzdG9yYWdlSWQpCiAgICAgewogICAgICAgICB2YXIgZG9tU3RvcmFnZSA9IHRoaXMu
X2RvbVN0b3JhZ2VGb3JJZChzdG9yYWdlSWQpOwo=
</data>

          </attachment>
      

    </bug>

</bugzilla>