{"id":18020730,"url":"https://github.com/inforkgodara/bubble-sort","last_synced_at":"2025-09-05T06:42:28.676Z","repository":{"id":110249723,"uuid":"233426654","full_name":"inforkgodara/bubble-sort","owner":"inforkgodara","description":"A single class implementation of bubble sort","archived":false,"fork":false,"pushed_at":"2020-08-02T11:22:22.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T17:16:49.360Z","etag":null,"topics":["bubble-sort","data-structures","inforkgodara","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inforkgodara.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-12T16:58:43.000Z","updated_at":"2020-08-03T13:46:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"6ac675dd-6f9c-49c9-8a81-b355d66ebcef","html_url":"https://github.com/inforkgodara/bubble-sort","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/inforkgodara/bubble-sort","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforkgodara%2Fbubble-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforkgodara%2Fbubble-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforkgodara%2Fbubble-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforkgodara%2Fbubble-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inforkgodara","download_url":"https://codeload.github.com/inforkgodara/bubble-sort/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforkgodara%2Fbubble-sort/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273723206,"owners_count":25156303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bubble-sort","data-structures","inforkgodara","java"],"created_at":"2024-10-30T06:07:27.139Z","updated_at":"2025-09-05T06:42:28.649Z","avatar_url":"https://github.com/inforkgodara.png","language":"Java","readme":"# Bubble Sort\n\nA simple single class implementation of bubble sort in Java. The user will be prompted to input the number of elements in a list which they want to enter. Sort method works by repeatedly swapping the adjacent elements if they are in the wrong order.\n\n## How to use it.\n* Open a command prompt window and go to the directory where you saved the java program (BubbleSort.java).\n* Type 'javac BubbleSort.java' and press enter to compile your code. If there are no errors in your code, the command prompt will take you to the next line.\n* Now, type 'java BubbleSort' to run your program.\n* You will be able to see an output line and asking input to enter the number of elements (integer) you want to enter.\n* Next you will enter the number of elements it can be space-separated or in a new line.\n* After completion of entering elements in list, the program will show sorted list.\n\n## Code\n```\nimport java.util.Scanner;\n\n/**\n * This is an implementation of the bubble sort algorithm.\n * @author @inforkgodara\n *\n */\npublic class BubbleSort {\n\n    /**\n     * Bubble sort implementation.\n     * @param list the array to be sorted.\n     * @param length the integer which size of list.\n     */\n    static void sort(int list[], int length) {\n        for (int i = 0; i \u003c length-1; i++) {\n            for (int j = 0; j \u003c length-i-1; j++) {\n                if (list[j] \u003e list[j+1])\n                {\n                    int temp = list[j];\n                    list[j] = list[j+1]; \n                    list[j+1] = temp; \n                }\n            } \n        }\n    }\n\n    public static void main(String[] args) {\n        System.out.print(\"Enter length of list : \");\n        Scanner scanner = new Scanner(System.in);\n\n        int length = scanner.nextInt();\n        int[] list = new int[length];\n\n        for (int index = 0; index \u003c length; index++) {\n            list[index] = scanner.nextInt();\n        }\n\n        sort(list, length);\n\n        System.out.print(\"Sorted list: \");\n\n        for (int element: list) {\n            System.out.print(element + \" \");\n        }\n    }\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finforkgodara%2Fbubble-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finforkgodara%2Fbubble-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finforkgodara%2Fbubble-sort/lists"}