Download the PHP package topshelfcraft/supersort without Composer

On this page you can find all versions of the php package topshelfcraft/supersort. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package supersort

SuperSort

...a super-duper sorting function for your Craft CMS templates.

A Top Shelf Craft creation
Michael Rog, Proprietor


What is SuperSort?

The SuperSort plugin provides a powerful Twig filter that helps with ordering an array of values — either using one of PHP's built-in methods to sort the actual values, or using custom "sort as" methods to arrange the array based on the rendered results of processing each member as a Twig object template.

Using SuperSort's "sort as" methods, you can sort an array of elements by any accessible object value — including values from Matrix blocks, attributes of related elements, math calculations, etc.

Usage

Installation

Visit the Plugin Store in your Craft control panel, search for SuperSort, and click to Install the plugin.

Or, if you're feeling frisky, you can install SuperSort via Composer:

composer require topshelfcraft/supersort

General usage

Use the supersort filter to sort an array of objects.

(You can apply supersort to any array or ElementQuery. A non-array-like source will be converted into a single-item array... which probably isn't very useful for sorting.)

Basic Sorting

The first parameter of the filter specifies the sort method.

{% set sortedSource = source | supersort('asort') %}

You can use any of PHP's built-in sort methods:

If you don't supply this first parameter, a plain vanilla asort will be applied:

{% set sortedSource = source | supersort %}

In many common cases — such as when you're sorting names, numbers, or filenames — the default 'asort' algorithm may produce unwanted results. In those cases, consider using the case-insensitive natural sorting algorithm ('natcasesort').

Advanced ("As") Sorting

You can also sort by one of SuperSort's custom methods:

To use these methods, you will provide a second parameter, which is a Twig object template to [render](https://docs.craftcms.com/api/v3/craft-web-view.html#renderObjectTemplate()-detail) using each object in the array:

{% set upcomingEvents = upcomingEvents | supersort('sortAs', '{eventDates.first.date}') %}

{% set upcomingEvents = upcomingEvents | supersort('sortAs', '{{ object.eventDates.first.date }}') %}

(This "object template" syntax is the same as you might use to define a Dynamic Subfolder Path for an Assets field.

Sort Flags

You can optionally provide a third parameter — one of PHP's sort flags.

{% set source = source | supersort('sortAs', '{foo}', SORT_NUMERIC) %}

{% set source = source | supersort('asort', null, SORT_NUMERIC) %}

If you don't supply this third parameter, the default (SORT_REGULAR) flag is used.

Using SuperSort as a PHP helper

If you'd like to use the superSort() method as a helper in another Craft plugin or component, you can access it in PHP directly from the Sorter service:

(Note: PHP's built-in sort methods sort an array in place and return a boolean representing success. The superSort() method, by contrast, returns the result array.)


Support

What are the system requirements?

Craft 4.0+ and PHP 8.0+

I found a bug.

Nah...

I triple-checked. It's a bug.

Well, alright. Please open a GitHub Issue, or submit a PR to the 4.x.dev branch.


Contributors:


All versions of supersort with dependencies

PHP Build Version
Package Version
Requires craftcms/cms Version ^5.0
topshelfcraft/base Version ^4.0.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package topshelfcraft/supersort contains the following files

Loading the files please wait ....