<!DOCTYPEhtml> <!-- Submitted from TestTWF Paris -->
<meta charset="utf-8">
<title>Key sort order</title>
<link rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#key-construct">
<link rel=assert title="For purposes of comparison, all Arrays are greater than all DOMString, Date and float values; all DOMString values are greater than all Date and float values; and all Date values are greater than all float values. Values of type float are compared to other float values numerically. Values of type Date are compared to other Date values chronologically. Values of type DOMString are compared to other values of type DOMString by using the algorithm defined by step 4 of section 11.8.5, The Abstract Relational Comparison Algorithm, of the ECMAScript Language Specification [ECMA-262]. Values of type Array are compared to other values of type Array as follows:
1. Let A be the first Array value and B be the second Array value.
2. Let length be the lesser of A's length and B's length.
3. Let i be 0.
4. If the ith value of A is less than the ith value of B, then A is less than B. Skip the remaining steps.
5. If the ith value of A is greater than the ith value of B, then A is greater than B. Skip the remaining steps.
6. Increase i by 1.
7. If i is not equal to length, go back to step 4. Otherwise continue to next step.
8. If A's length is less than B's length, then A is less than B. If A's length is greater than B's length, then A is greater than B. Otherwise A and B are equal.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/support.js"></script>
<script> var global_db = createdb_for_multiple_tests();
function keysort(desc, unsorted, expected) { var db,
t = async_test("Database readback sort - " + desc),
store_name = 'store-' + Date.now() + Math.random();
// The database test var open_rq = global_db.setTest(t);
open_rq.onupgradeneeded = function(e) {
db = e.target.result; var objStore = db.createObjectStore(store_name);
for (var i = 0; i < unsorted.length; i++)
objStore.add("value", unsorted[i]);
};
// The IDBKey.cmp test
test(function () { var sorted = unsorted.slice(0).sort(function(a, b) { return indexedDB.cmp(a, b)});
assert_key_equals(sorted, expected, "sorted array");
}, "IDBKey.cmp sorted - " + desc);
}
var now = new Date(),
one_sec_ago = new Date(now - 1000),
one_min_future = new Date(now.getTime() + (1000*60));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.