Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "sort_dict"

Title:Sorts dicts by key
Rating:Not rated. Create the first rating!
Latest version:0.0.3
SHA1 sum:d9c1a6dd2f6107143fde960282b55eea6584a4ee
Author:Raivo Laanemets http://rlaanemets.com/
Home page:https://github.com/rla/sort-dict

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
0.0.12fa7c99cc7692f426682b04b0689fe65b58a83982http://packs.rlaanemets.com/sort-dict/sort_dict-0.0.1.tgz
0.0.2f0350d538b7c3a9aceaef851550fe95a63ea83b02http://packs.rlaanemets.com/sort-dict/sort_dict-0.0.2.tgz
0.0.3d9c1a6dd2f6107143fde960282b55eea6584a4ee116http://packs.rlaanemets.com/sort-dict/sort_dict-0.0.3.tgz

sort_dict

Sorts list of dicts by key in the given direction. Duplicate entries are not removed.

Example

Sorting some things by the key weight in the descending order:

?- sort_dict(weight, desc, [
        object{ name: paper, weight: 0.01 },
        object{ name: rock, weight: 1.0 },
        object{ name: scrissors, weight: 0.2 }
    ], Sorted).
?- Sorted = [
    object{ name:rock, weight:1.0 },
    object{ name:scrissors, weight:0.2 },
    object{ name:paper, weight:0.01 }
].

Installation

This package requires Swi-Prolog 7.x.

pack_install(sort_dict).

Known issues

Sorting is not stable.

Bug reports/feature requests

Please send bug reports/feature request through the GitHub project page.

API documentation

See http://packs.rlaanemets.com/sort-dict/doc/.

Changelog

  • 2014-04-22 v0.0.3 - uses dot notation instead of get_dict_ex/3.
  • 2014-02-13 v0.0.2 - uses @< for comparing.
  • 2014-02-04 v0.0.1

License

The MIT License. See LICENSE file.

Contents of pack "sort_dict"

Pack contains 5 files holding a total of 5.4K bytes.