File tree 2 files changed +33
-0
lines changed
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -18,3 +18,22 @@ or to check if a constraint is a subset of another constraint.
18
18
All that is done to let us select which version is compatible with a user constraints.
19
19
20
20
It works with the same rules of Composer versioning.
21
+
22
+ ### Sorting
23
+ In order to use standard PHP sorting there is a helper class 'Compare' to use it with a sort you will need to do this;
24
+
25
+ ``` php
26
+ use Version\Version;
27
+ use Version\Compare;
28
+
29
+ $vers = array();
30
+ $vers[] = Version::parse('1.1.1d1');
31
+ $vers[] = '1.1.1';
32
+
33
+ $obj = new Compare();
34
+ usort( $vers, array( $obj, 'compare' ) );
35
+ ```
36
+
37
+ The above should allow any normal PHP sort to be instigated with very little effort.
38
+
39
+ ** Note** : You should see that it will handle a string or a Version object as the variable to sort automatically.
Original file line number Diff line number Diff line change
1
+ <?php
2
+ namespace Version ;
3
+
4
+ use Version \Version ;
5
+
6
+ class Compare
7
+ {
8
+ public function compare ( $ v1 , $ v2 )
9
+ {
10
+ $ va1 = ( $ v1 instanceof Version ) ? $ v1 : Version::parse ( $ v1 );
11
+ $ va2 = ( $ v2 instanceof Version ) ? $ v2 : Version::parse ( $ v2 );
12
+ return ( $ va1 ->compare ( $ va2 ) );
13
+ }
14
+ }
You can’t perform that action at this time.
0 commit comments