Search

Showing 7 of 1,216 result(s)

/blog/2016/11/30/laravel-collection-public-api-sortby#content-sortby-options

The $options parameter allows developers to change the sorting behavior of the sortBy method. The accepted options are the same options that are defined for PHP's sort function. The following collection instance will be used throughout this...

/blog/2016/11/30/laravel-collection-public-api-sortby#content-sorting-flag-comparison-table

The following tables will show how the different sorting flags change the sorting of the previously made $collection . Each sorting flag has its own section, which will follow this section. The first table shows the key and its associated value...

/blog/2016/11/30/laravel-collection-public-api-sortby#content-collection-keys-and-values

Key Data Type Value 0 string a2.txt 1 string a1.txt 2 string a4.txt 3 object (Animal) KANGAROO 4 object (Animal) kangaroo 5 string a3.txt 6 integer 6 7 integer 5 8 object (Animal) macaw 9 string candice 10 string bob 11 string alice 12 object...

/blog/2016/11/30/laravel-collection-public-api-sortby#content-sorting-flag-result-comparison

Option Result Original Order 0 1 2 3 4 5 6 7 8 9 10 11 12 SORT_REGULAR 7 6 3 1 0 5 2 11 10 9 4 8 12 SORT_NUMERIC 8 9 10 11 0 5 2 1 3 4 12 7 6 SORT_STRING 7 6 3 1 0 5 2 11 10 9 4 8 12 SORT_STRING | SORT_FLAG_CASE 7 6 1 0 5 2...

/blog/2016/11/30/laravel-collection-public-api-sortby#content-sortnumeric

The SORT_NUMERIC treats each item as a number when doing the comparison. The following code example shows how to use the SORT_NUMERIC flag when sorting the $collection created previously (the callback function will return the string representation...

/blog/2016/11/30/laravel-collection-public-api-sortby#content-sortnumeric-result-comparision

Option Result Original Order 0 1 2 3 4 5 6 7 8 9 10 11 12 SORT_REGULAR 7 6 3 1 0 5 2 11 10 9 4 8 12 SORT_NUMERIC 8 9 10 11 0 5 2 1 3 4 12 7 6

/blog/2016/11/30/laravel-collection-public-api-sortby#content-sortstring

The SORT_STRING treats each item as a string when doing the comparison. The following code example shows how to use the SORT_STRING flag when sorting the $collection created previously (the callback function will return the string representation...