Stable quicksort in Javascript
October 28th, 2008
Firefox < v3.0 doesn't have a stable Array.sort() function - that is, it doesn't maintain indexes for elements of equal value. This is undefined in the ECMA spec, and has been fixed in Firefox as of version 3 (and curiously enough has been stable in IE all along). As a result, I set out to find a stable, efficient Array.sort() replacement/supplement.
Read the rest of this entry »
MySQL inner join to perform update from same table
September 9th, 2008
Typically, using SELECT in a subquery to perform an UPDATE on the same table, such as:
UPDATE table1 AS target
SET field1 = (
SELECT field2
FROM table1 AS source
WHERE source.id = target.id
)
is illegal in MySQL. To achieve the desired effect, you can perform an INNER JOIN in the UPDATE:
UPDATE table1 AS target INNER JOIN table1 AS source USING(id) SET target.field1 = source.field2