Skip to content
This repository was archived by the owner on Jun 29, 2025. It is now read-only.

davidglezmartin/vue-orderBy-mixin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

vue-orderBy mixin

Sort a array object with a custom field

Install

$ npm install vue-orderby-mixin

Usage

this.orderBy(obj, column, type)

	obj => Array object
	column => A custom field for sorting
	type => ASC or DESC
    

Example

import orderBy from 'vue-orderby-mixin'
	export default {
		data () {
	    	return {
	    		users: [
        	  		{ id: 1, name: 'John' },
        	  		{ id: 2, name: 'Jane' }
        		],
	    	}
	    },
		mixins: { orderBy },
		methods: {
			example () {
				this.orderBy(this.users, 'name', 'ASC')
			}
		}
	}

Result

id name
2 Jane
1 John

About

Sort a array object with a custom field.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published