Views sort criteria setup by number of fields
It should be something like this. (It is not the exact code, but it will help you.)

function findNodesByUser($userID) {
$result = $query
  -&gt;entityCondition('entity_type', 'node')
  -&gt;propertyCondition('status', 1)
  -&gt;propertyCondition('type', $type) //Where $type is the type of node
  -&gt;propertyCondition('uid', $userID)
  -&gt;execute();
}

function createArray() {
    customArray = array();
    $users = entity_load('user');

    foreach ($users as $user) {
        $user_nodes = findNodesByUser($user);
        foreach($user_nodes as $user_node) {
            customArray[$user . $user_node] = count(field_get_items('node', $entity, $field_name));
        }
    }
}