「降順で並び替え」の版間の差分

提供:MeryWiki
ナビゲーションに移動 検索に移動
編集の要約なし
(→‎ソースコード: 省略された波括弧の追加)
 
(同じ利用者による、間の2版が非表示)
1行目: 1行目:
このマクロはMeryのMacrosフォルダに同梱されています。
== 概要 ==
編集中の文書の行を降順で並べ替えます。
編集中の文書の行を降順で並べ替えます。


<source lang="javascript">
== ソースコード ==
<syntaxhighlight lang="javascript">
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// 降順で並べ替え
// 降順で並べ替え
//
//
// Copyright (c) Kuro. All Rights Reserved.
// Copyright (c) Kuro. All Rights Reserved.
// www:    http://www.haijin-boys.com/
// www:    https://www.haijin-boys.com/
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------


if (document.selection.Text == "")
if (document.selection.Text == "") {
   document.selection.SelectAll();
   document.selection.SelectAll();
}
document.selection.Text = document.selection.Text.split("\n").sort(
document.selection.Text = document.selection.Text.split("\n").sort(
   function(a, b) {
   function(a, b) {
17行目: 22行目:
).join("\n");
).join("\n");
document.selection.StartOfDocument();
document.selection.StartOfDocument();
</source>
</syntaxhighlight>

2023年10月20日 (金) 14:35時点における最新版

このマクロはMeryのMacrosフォルダに同梱されています。

概要[編集]

編集中の文書の行を降順で並べ替えます。

ソースコード[編集]

// -----------------------------------------------------------------------------
// 降順で並べ替え
//
// Copyright (c) Kuro. All Rights Reserved.
// www:    https://www.haijin-boys.com/
// -----------------------------------------------------------------------------

if (document.selection.Text == "") {
  document.selection.SelectAll();
}
document.selection.Text = document.selection.Text.split("\n").sort(
  function(a, b) {
    return ((a < b) ? 1 : ((a > b) ? -1 : 0));
  }
).join("\n");
document.selection.StartOfDocument();
スポンサーリンク