views:

101

answers:

3

I'm writing a GreaseMonkey script, as part of which I'd like to sort a list by dragging its items. I'm using mootools, but the component for sortable lists doesn't work in the GM sandboxed environment. Can you recommend a smallish library/piece of code to do list sorting in the most lightweight fashion? I want it to be independant of any large framework and don't feel like implementing it myself.

A: 

Use this Javascript QuickSort implementation

Josh Stodola
The question is, does that work in greasemonkey? ;)
Crescent Fresh
Why wouldn't it?
Josh Stodola
That's not really what I wanna do, I need to sort lists in an arbitrary way by dragging the items.
VoY
A: 

I'm not sure if there are any particular issues with just MooTools, but in general you may include external scripts into a GreaseMonkey script.

This has been addressed in previous questions like this one or this, as well as on the GreaseSpot wiki.

stefpet
There are issues with the component I need from mootools-more... unfortunately it doesn't work and the way GM reports errors makes it near impossible to debug, as it doesn't tell me the number of the offending line.
VoY
+1  A: 

If you need to debug a library such as mootools, instead of @require-ing it, just copy/paste the entire source into your own script. Then you can debug it the same as your own code.

On another note, this script includes the ability to drag-and-drop it's own window around the screen, with no additional library. Maybe you could analyze it and borrow code?

Lil Devil