How to apply weighted filter to combination? I need to find ordering of combination, Combination examples are as follows:
User A Selects in this order: 


*

*Eye-Brown, 2. Pet-Dog, 3. Diet-Carnivore, 4. Body Type-Thin, 5. Hair length-Short 


Total numbers may be dynamic, e.g. there may be more than 5 selections then combination would be different.
From above selection i need to find other users having combination percentage as follows: 
100% Matching: 
1,2,3,4,5
Then from the 80% Matching, first show: 
Weight is decreasing
1,2,3,4,X higher weight as first four matched
1,2,3,X,5  
1,2,X,4,5
1,X,3,4,5
X,2,3,4,5 lowest weight in 80% match, as last four selected 
From 60% Matching Users, show in this order: 
1,2,3,X,X 
1,2,X,4,X 
1,2,X,X,5 
1,X,3,4,X 
1,X,3,X,5 
1,X,X,4,5 
X,2,3,4,X 
X,2,3,X,5 
X,2,X,4,5 
X,X,3,4,5
From 40%:
1,2,X,X,X 
1,X,3,X,X 
1,X,X,4,X 
1,X,X,X,5 
X,2,3,X,X 
X,2,X,4,X 
X,2,X,X,5 
X,X,3,4,X 
X,X,3,X,5 
X,X,X,4,5
According to above combination, i am trying to get formula from which i can sort this data.
I need particular value of individual combination so that i can sort that combination according to that.
 A: For $n$ properties, if we define == as any boolean string comparison routine such as strcomp, $\text int(\cdot)$ casting from boolean to integer (0,1) for converting from the real world into something numerically acceptable, the value of each property is:
$p_i=\text{int}($property{i}==value{i}$), i=1 ... n$
And the requested fraction (percentage) is just:
$$
p=\frac 1n\sum_{i=1}^np_i
$$
EDIT:
Now you need some code, for converting from real world into acceptable values (in Matlab):
n=5;
property={'Brown','Dog','Carnivore','Thin','Short'};
value={'Black','Shark','Carnivore','Smooth','None'};
for i=1:n
    pi(i)=strcmp(property{i},value{i});
end
p=sum(pi)/n

This will output the value p=0.2, because you just fit in the 'Carnivore' property.
If you output $p_i$: pi=[0 0 1 0 0], showing the function strcmp only equals for the third property.
EDIT:
An unique ID could be the sum of the given values:
$$
ID=\sum_{i=1}^n \text{values}_i
$$
Hence ID([1 2 3 X X])=6 and ID([1 2 X 4 X])=7.
For sorting, you put both $p$ and $ID$ numbers in a same matrix, and sort according the first then the second columns:
A=sortrows([p ID],[1 2]);

