mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-20 14:45:59 +00:00
33 lines
589 B
JavaScript
33 lines
589 B
JavaScript
![]() |
/*\
|
||
|
title: $:/core/modules/filters/sort.js
|
||
|
type: application/javascript
|
||
|
module-type: filteroperator
|
||
|
|
||
|
Filter operator for sorting
|
||
|
|
||
|
\*/
|
||
|
(function(){
|
||
|
|
||
|
/*jslint node: true, browser: true */
|
||
|
/*global $tw: false */
|
||
|
"use strict";
|
||
|
|
||
|
/*
|
||
|
Export our filter function
|
||
|
*/
|
||
|
exports.sort = function(source,operator,options) {
|
||
|
var results;
|
||
|
if($tw.utils.isArray(source)) {
|
||
|
results = source;
|
||
|
} else {
|
||
|
results = [];
|
||
|
$tw.utils.each(source,function(element,title) {
|
||
|
results.push(title);
|
||
|
});
|
||
|
}
|
||
|
options.wiki.sortTiddlers(results,operator.operand,operator.prefix === "!");
|
||
|
return results;
|
||
|
};
|
||
|
|
||
|
})();
|